{"action":"closed","number":1,"pull_request":{"url":"https://api.github.com/repos/snu-sf/clang-freeze/pulls/1","id":82124930,"html_url":"https://github.com/snu-sf/clang-freeze/pull/1","diff_url":"https://github.com/snu-sf/clang-freeze/pull/1.diff","patch_url":"https://github.com/snu-sf/clang-freeze/pull/1.patch","issue_url":"https://api.github.com/repos/snu-sf/clang-freeze/issues/1","number":1,"state":"closed","locked":false,"title":"Add freeze instruction in Bit Field","user":{"login":"aqjune","id":6484889,"avatar_url":"https://avatars.githubusercontent.com/u/6484889?v=3","gravatar_id":"","url":"https://api.github.com/users/aqjune","html_url":"https://github.com/aqjune","followers_url":"https://api.github.com/users/aqjune/followers","following_url":"https://api.github.com/users/aqjune/following{/other_user}","gists_url":"https://api.github.com/users/aqjune/gists{/gist_id}","starred_url":"https://api.github.com/users/aqjune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aqjune/subscriptions","organizations_url":"https://api.github.com/users/aqjune/orgs","repos_url":"https://api.github.com/users/aqjune/repos","events_url":"https://api.github.com/users/aqjune/events{/privacy}","received_events_url":"https://api.github.com/users/aqjune/received_events","type":"User","site_admin":false},"body":"Added freeze instruction at `EmitStoreThroughBitfieldLValue`.\r\n\r\nI checked that generated IR code of storing a value into a bitfield (`a.x = t`) contains newly inserted freeze instructions. I freezed both `a.x` and `t`, because otherwise other fields in `a` still can be undef value.\r\n\r\nI checked this using C/C++ sample code. Here is the following code.\r\n\r\nC : \r\n```\r\nstruct A{\r\n  int x:3;\r\n  int y:6;\r\n  int z:7;\r\n};\r\n\r\nint f1(int arg){\r\n  int value = arg;\r\n  struct A a;\r\n  a.y = value;\r\n  return a.y + 1234;\r\n}\r\n```\r\n\r\nIR : \r\n```\r\n%struct.A = type { i16, [2 x i8] }\r\n%union.B = type { i8, [3 x i8] }\r\n\r\n; Function Attrs: nounwind uwtable\r\ndefine i32 @f1(i32 %arg) #0 {\r\nentry:\r\n  ; JuneyoungLee : Declarations\r\n  %arg.addr = alloca i32, align 4\r\n  %value = alloca i32, align 4\r\n  %a = alloca %struct.A, align 4\r\n  store i32 %arg, i32* %arg.addr, align 4\r\n  %0 = load i32, i32* %arg.addr, align 4\r\n  store i32 %0, i32* %value, align 4\r\n  ; C statement : a.y = value;\r\n  ; Step 1) Load `value` and `a`\r\n  %1 = load i32, i32* %value, align 4\r\n  %2 = bitcast %struct.A* %a to i16*\r\n  %3 = trunc i32 %1 to i16\r\n  %4 = freeze i16 %3\r\n  %bf.load = load i16, i16* %2, align 4\r\n  %5 = freeze i16 %bf.load\r\n  ; Step 2) Calculate updated value using bit operations\r\n  %bf.value = and i16 %4, 63\r\n  %bf.shl = shl i16 %bf.value, 3\r\n  %bf.clear = and i16 %5, -505\r\n  %bf.set = or i16 %bf.clear, %bf.shl\r\n  ; Step 3) Store the updated value into alloca\r\n  store i16 %bf.set, i16* %2, align 4\r\n  ; Step 4) Save the result into registers so that it could be used later\r\n  %bf.result.shl = shl i16 %bf.value, 10\r\n  %bf.result.ashr = ashr i16 %bf.result.shl, 10\r\n  %bf.result.cast = sext i16 %bf.result.ashr to i32\r\n  ; C statement : return (unsigned int)a.y + 1234;\r\n  %6 = bitcast %struct.A* %a to i16*\r\n  %bf.load1 = load i16, i16* %6, align 4\r\n   %bf.shl2 = shl i16 %bf.load1, 7    \r\n   %bf.ashr = ashr i16 %bf.shl2, 10   \r\n   %bf.cast = sext i16 %bf.ashr to i32\r\n   %add = add nsw i32 %bf.cast, 1234  \r\n  ret i32 %add\r\n}\r\n```\r\n\r\nI attach sample codes (run.c / run.c.O0.ll / run.cpp / run.cpp.O0ll).\r\n[bitfield.zip](https://github.com/snu-sf/clang-freeze/files/429232/bitfield.zip)","created_at":"2016-08-22T01:44:18Z","updated_at":"2016-08-22T09:05:09Z","closed_at":"2016-08-22T09:05:09Z","merged_at":"2016-08-22T09:05:09Z","merge_commit_sha":"a14f3c8ceca9512a0bf1fc5b696596b7eef60332","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/snu-sf/clang-freeze/pulls/1/commits","review_comments_url":"https://api.github.com/repos/snu-sf/clang-freeze/pulls/1/comments","review_comment_url":"https://api.github.com/repos/snu-sf/clang-freeze/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snu-sf/clang-freeze/issues/1/comments","statuses_url":"https://api.github.com/repos/snu-sf/clang-freeze/statuses/decaa7011d261a522a82ae9a86c18bb4df7fd161","head":{"label":"aqjune:bitfield-freeze","ref":"bitfield-freeze","sha":"decaa7011d261a522a82ae9a86c18bb4df7fd161","user":{"login":"aqjune","id":6484889,"avatar_url":"https://avatars.githubusercontent.com/u/6484889?v=3","gravatar_id":"","url":"https://api.github.com/users/aqjune","html_url":"https://github.com/aqjune","followers_url":"https://api.github.com/users/aqjune/followers","following_url":"https://api.github.com/users/aqjune/following{/other_user}","gists_url":"https://api.github.com/users/aqjune/gists{/gist_id}","starred_url":"https://api.github.com/users/aqjune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aqjune/subscriptions","organizations_url":"https://api.github.com/users/aqjune/orgs","repos_url":"https://api.github.com/users/aqjune/repos","events_url":"https://api.github.com/users/aqjune/events{/privacy}","received_events_url":"https://api.github.com/users/aqjune/received_events","type":"User","site_admin":false},"repo":{"id":66214061,"name":"clang-freeze","full_name":"aqjune/clang-freeze","owner":{"login":"aqjune","id":6484889,"avatar_url":"https://avatars.githubusercontent.com/u/6484889?v=3","gravatar_id":"","url":"https://api.github.com/users/aqjune","html_url":"https://github.com/aqjune","followers_url":"https://api.github.com/users/aqjune/followers","following_url":"https://api.github.com/users/aqjune/following{/other_user}","gists_url":"https://api.github.com/users/aqjune/gists{/gist_id}","starred_url":"https://api.github.com/users/aqjune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aqjune/subscriptions","organizations_url":"https://api.github.com/users/aqjune/orgs","repos_url":"https://api.github.com/users/aqjune/repos","events_url":"https://api.github.com/users/aqjune/events{/privacy}","received_events_url":"https://api.github.com/users/aqjune/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aqjune/clang-freeze","description":null,"fork":true,"url":"https://api.github.com/repos/aqjune/clang-freeze","forks_url":"https://api.github.com/repos/aqjune/clang-freeze/forks","keys_url":"https://api.github.com/repos/aqjune/clang-freeze/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aqjune/clang-freeze/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aqjune/clang-freeze/teams","hooks_url":"https://api.github.com/repos/aqjune/clang-freeze/hooks","issue_events_url":"https://api.github.com/repos/aqjune/clang-freeze/issues/events{/number}","events_url":"https://api.github.com/repos/aqjune/clang-freeze/events","assignees_url":"https://api.github.com/repos/aqjune/clang-freeze/assignees{/user}","branches_url":"https://api.github.com/repos/aqjune/clang-freeze/branches{/branch}","tags_url":"https://api.github.com/repos/aqjune/clang-freeze/tags","blobs_url":"https://api.github.com/repos/aqjune/clang-freeze/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aqjune/clang-freeze/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aqjune/clang-freeze/git/refs{/sha}","trees_url":"https://api.github.com/repos/aqjune/clang-freeze/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aqjune/clang-freeze/statuses/{sha}","languages_url":"https://api.github.com/repos/aqjune/clang-freeze/languages","stargazers_url":"https://api.github.com/repos/aqjune/clang-freeze/stargazers","contributors_url":"https://api.github.com/repos/aqjune/clang-freeze/contributors","subscribers_url":"https://api.github.com/repos/aqjune/clang-freeze/subscribers","subscription_url":"https://api.github.com/repos/aqjune/clang-freeze/subscription","commits_url":"https://api.github.com/repos/aqjune/clang-freeze/commits{/sha}","git_commits_url":"https://api.github.com/repos/aqjune/clang-freeze/git/commits{/sha}","comments_url":"https://api.github.com/repos/aqjune/clang-freeze/comments{/number}","issue_comment_url":"https://api.github.com/repos/aqjune/clang-freeze/issues/comments{/number}","contents_url":"https://api.github.com/repos/aqjune/clang-freeze/contents/{+path}","compare_url":"https://api.github.com/repos/aqjune/clang-freeze/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aqjune/clang-freeze/merges","archive_url":"https://api.github.com/repos/aqjune/clang-freeze/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aqjune/clang-freeze/downloads","issues_url":"https://api.github.com/repos/aqjune/clang-freeze/issues{/number}","pulls_url":"https://api.github.com/repos/aqjune/clang-freeze/pulls{/number}","milestones_url":"https://api.github.com/repos/aqjune/clang-freeze/milestones{/number}","notifications_url":"https://api.github.com/repos/aqjune/clang-freeze/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aqjune/clang-freeze/labels{/name}","releases_url":"https://api.github.com/repos/aqjune/clang-freeze/releases{/id}","deployments_url":"https://api.github.com/repos/aqjune/clang-freeze/deployments","created_at":"2016-08-21T18:27:18Z","updated_at":"2016-08-21T18:27:43Z","pushed_at":"2016-08-21T18:37:03Z","git_url":"git://github.com/aqjune/clang-freeze.git","ssh_url":"git@github.com:aqjune/clang-freeze.git","clone_url":"https://github.com/aqjune/clang-freeze.git","svn_url":"https://github.com/aqjune/clang-freeze","homepage":null,"size":265373,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"snu-sf:master","ref":"master","sha":"071180678d2add49ebfe64e5d6625fe01b235302","user":{"login":"snu-sf","id":8771070,"avatar_url":"https://avatars.githubusercontent.com/u/8771070?v=3","gravatar_id":"","url":"https://api.github.com/users/snu-sf","html_url":"https://github.com/snu-sf","followers_url":"https://api.github.com/users/snu-sf/followers","following_url":"https://api.github.com/users/snu-sf/following{/other_user}","gists_url":"https://api.github.com/users/snu-sf/gists{/gist_id}","starred_url":"https://api.github.com/users/snu-sf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snu-sf/subscriptions","organizations_url":"https://api.github.com/users/snu-sf/orgs","repos_url":"https://api.github.com/users/snu-sf/repos","events_url":"https://api.github.com/users/snu-sf/events{/privacy}","received_events_url":"https://api.github.com/users/snu-sf/received_events","type":"Organization","site_admin":false},"repo":{"id":62033847,"name":"clang-freeze","full_name":"snu-sf/clang-freeze","owner":{"login":"snu-sf","id":8771070,"avatar_url":"https://avatars.githubusercontent.com/u/8771070?v=3","gravatar_id":"","url":"https://api.github.com/users/snu-sf","html_url":"https://github.com/snu-sf","followers_url":"https://api.github.com/users/snu-sf/followers","following_url":"https://api.github.com/users/snu-sf/following{/other_user}","gists_url":"https://api.github.com/users/snu-sf/gists{/gist_id}","starred_url":"https://api.github.com/users/snu-sf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snu-sf/subscriptions","organizations_url":"https://api.github.com/users/snu-sf/orgs","repos_url":"https://api.github.com/users/snu-sf/repos","events_url":"https://api.github.com/users/snu-sf/events{/privacy}","received_events_url":"https://api.github.com/users/snu-sf/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/snu-sf/clang-freeze","description":null,"fork":false,"url":"https://api.github.com/repos/snu-sf/clang-freeze","forks_url":"https://api.github.com/repos/snu-sf/clang-freeze/forks","keys_url":"https://api.github.com/repos/snu-sf/clang-freeze/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snu-sf/clang-freeze/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snu-sf/clang-freeze/teams","hooks_url":"https://api.github.com/repos/snu-sf/clang-freeze/hooks","issue_events_url":"https://api.github.com/repos/snu-sf/clang-freeze/issues/events{/number}","events_url":"https://api.github.com/repos/snu-sf/clang-freeze/events","assignees_url":"https://api.github.com/repos/snu-sf/clang-freeze/assignees{/user}","branches_url":"https://api.github.com/repos/snu-sf/clang-freeze/branches{/branch}","tags_url":"https://api.github.com/repos/snu-sf/clang-freeze/tags","blobs_url":"https://api.github.com/repos/snu-sf/clang-freeze/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snu-sf/clang-freeze/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snu-sf/clang-freeze/git/refs{/sha}","trees_url":"https://api.github.com/repos/snu-sf/clang-freeze/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snu-sf/clang-freeze/statuses/{sha}","languages_url":"https://api.github.com/repos/snu-sf/clang-freeze/languages","stargazers_url":"https://api.github.com/repos/snu-sf/clang-freeze/stargazers","contributors_url":"https://api.github.com/repos/snu-sf/clang-freeze/contributors","subscribers_url":"https://api.github.com/repos/snu-sf/clang-freeze/subscribers","subscription_url":"https://api.github.com/repos/snu-sf/clang-freeze/subscription","commits_url":"https://api.github.com/repos/snu-sf/clang-freeze/commits{/sha}","git_commits_url":"https://api.github.com/repos/snu-sf/clang-freeze/git/commits{/sha}","comments_url":"https://api.github.com/repos/snu-sf/clang-freeze/comments{/number}","issue_comment_url":"https://api.github.com/repos/snu-sf/clang-freeze/issues/comments{/number}","contents_url":"https://api.github.com/repos/snu-sf/clang-freeze/contents/{+path}","compare_url":"https://api.github.com/repos/snu-sf/clang-freeze/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snu-sf/clang-freeze/merges","archive_url":"https://api.github.com/repos/snu-sf/clang-freeze/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snu-sf/clang-freeze/downloads","issues_url":"https://api.github.com/repos/snu-sf/clang-freeze/issues{/number}","pulls_url":"https://api.github.com/repos/snu-sf/clang-freeze/pulls{/number}","milestones_url":"https://api.github.com/repos/snu-sf/clang-freeze/milestones{/number}","notifications_url":"https://api.github.com/repos/snu-sf/clang-freeze/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snu-sf/clang-freeze/labels{/name}","releases_url":"https://api.github.com/repos/snu-sf/clang-freeze/releases{/id}","deployments_url":"https://api.github.com/repos/snu-sf/clang-freeze/deployments","created_at":"2016-06-27T07:19:04Z","updated_at":"2016-08-17T05:58:36Z","pushed_at":"2016-08-22T09:05:09Z","git_url":"git://github.com/snu-sf/clang-freeze.git","ssh_url":"git@github.com:snu-sf/clang-freeze.git","clone_url":"https://github.com/snu-sf/clang-freeze.git","svn_url":"https://github.com/snu-sf/clang-freeze","homepage":null,"size":265259,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snu-sf/clang-freeze/pulls/1"},"html":{"href":"https://github.com/snu-sf/clang-freeze/pull/1"},"issue":{"href":"https://api.github.com/repos/snu-sf/clang-freeze/issues/1"},"comments":{"href":"https://api.github.com/repos/snu-sf/clang-freeze/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/snu-sf/clang-freeze/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/snu-sf/clang-freeze/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snu-sf/clang-freeze/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/snu-sf/clang-freeze/statuses/decaa7011d261a522a82ae9a86c18bb4df7fd161"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"aqjune","id":6484889,"avatar_url":"https://avatars.githubusercontent.com/u/6484889?v=3","gravatar_id":"","url":"https://api.github.com/users/aqjune","html_url":"https://github.com/aqjune","followers_url":"https://api.github.com/users/aqjune/followers","following_url":"https://api.github.com/users/aqjune/following{/other_user}","gists_url":"https://api.github.com/users/aqjune/gists{/gist_id}","starred_url":"https://api.github.com/users/aqjune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aqjune/subscriptions","organizations_url":"https://api.github.com/users/aqjune/orgs","repos_url":"https://api.github.com/users/aqjune/repos","events_url":"https://api.github.com/users/aqjune/events{/privacy}","received_events_url":"https://api.github.com/users/aqjune/received_events","type":"User","site_admin":false},"comments":2,"review_comments":0,"commits":1,"additions":7,"deletions":0,"changed_files":1}}
{"actor":{"display_login":"aqjune"}}