{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/llilc/pulls/comments/38053532","id":38053532,"diff_hunk":"@@ -5994,8 +5994,35 @@ void GenIR::switchOpcode(IRNode *Opr) {\n   BasicBlock *CurrBlock = LLVMBuilder->GetInsertBlock();\n   TerminatorInst *TermInst = CurrBlock->getTerminator();\n   SwitchInst *SwitchInstruction = cast<SwitchInst>(TermInst);\n-\n   SwitchInstruction->setCondition(Opr);\n+\n+  Type *OprType = Opr->getType();\n+  LLVMContext &LLVMContext = *this->JitContext->LLVMContext;\n+  Type *Int32Ty = Type::getInt32Ty(LLVMContext);\n+  if (OprType != Int32Ty) {\n+    // When we made the case values we assumed int32 as the type for the\n+    // values. But now we have an operand of a different type. LLVM\n+    // requires the values and the switch value to have the same type.\n+    // So change the type of the values to be the type of the selector.\n+    IntegerType *OprIntType = cast<IntegerType>(OprType);\n+\n+    // If a small selector type was used, e.g. i8, the type might not\n+    // be big enough to hold all the case values. But the value for the\n+    // selector is popped off the evaluation stack, so it should be at\n+    // least 32 bits. So check that.\n+    unsigned OprBitWidth = OprIntType->getBitWidth();\n+    assert((OprBitWidth > 32) && \"Selector bit width is less then 32\");\n+\n+    // Create new values of the correct type.\n+    int NumCases = SwitchInstruction->getNumCases();\n+    SwitchInst::CaseIt Case = SwitchInstruction->case_begin();\n+    for (size_t I = 0; I < NumCases; I++) {\n+      ConstantInt *Value = ConstantInt::get(\n+          *JitContext->LLVMContext, APInt(OprBitWidth, (uint64_t)I, false));","path":"lib/Reader/readerir.cpp","position":29,"original_position":29,"commit_id":"74a1f26cca209ab325b512a715617ebea6a4d0f0","original_commit_id":"74a1f26cca209ab325b512a715617ebea6a4d0f0","user":{"login":"JosephTremoulet","id":10655216,"avatar_url":"https://avatars.githubusercontent.com/u/10655216?v=3","gravatar_id":"","url":"https://api.github.com/users/JosephTremoulet","html_url":"https://github.com/JosephTremoulet","followers_url":"https://api.github.com/users/JosephTremoulet/followers","following_url":"https://api.github.com/users/JosephTremoulet/following{/other_user}","gists_url":"https://api.github.com/users/JosephTremoulet/gists{/gist_id}","starred_url":"https://api.github.com/users/JosephTremoulet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JosephTremoulet/subscriptions","organizations_url":"https://api.github.com/users/JosephTremoulet/orgs","repos_url":"https://api.github.com/users/JosephTremoulet/repos","events_url":"https://api.github.com/users/JosephTremoulet/events{/privacy}","received_events_url":"https://api.github.com/users/JosephTremoulet/received_events","type":"User","site_admin":false},"body":"Should this maybe assert that the value we're replacing was in fact (32-bit) I?","created_at":"2015-08-27T01:05:56Z","updated_at":"2015-08-27T01:05:56Z","html_url":"https://github.com/dotnet/llilc/pull/800#discussion_r38053532","pull_request_url":"https://api.github.com/repos/dotnet/llilc/pulls/800","_links":{"self":{"href":"https://api.github.com/repos/dotnet/llilc/pulls/comments/38053532"},"html":{"href":"https://github.com/dotnet/llilc/pull/800#discussion_r38053532"},"pull_request":{"href":"https://api.github.com/repos/dotnet/llilc/pulls/800"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/llilc/pulls/800","id":43463232,"html_url":"https://github.com/dotnet/llilc/pull/800","diff_url":"https://github.com/dotnet/llilc/pull/800.diff","patch_url":"https://github.com/dotnet/llilc/pull/800.patch","issue_url":"https://api.github.com/repos/dotnet/llilc/issues/800","number":800,"state":"open","locked":false,"title":"Fix #789 and #797","user":{"login":"richardlford","id":6829071,"avatar_url":"https://avatars.githubusercontent.com/u/6829071?v=3","gravatar_id":"","url":"https://api.github.com/users/richardlford","html_url":"https://github.com/richardlford","followers_url":"https://api.github.com/users/richardlford/followers","following_url":"https://api.github.com/users/richardlford/following{/other_user}","gists_url":"https://api.github.com/users/richardlford/gists{/gist_id}","starred_url":"https://api.github.com/users/richardlford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardlford/subscriptions","organizations_url":"https://api.github.com/users/richardlford/orgs","repos_url":"https://api.github.com/users/richardlford/repos","events_url":"https://api.github.com/users/richardlford/events{/privacy}","received_events_url":"https://api.github.com/users/richardlford/received_events","type":"User","site_admin":false},"body":"Closes #789. Closes #797.\r\n\r\nFor #789, when merging stack states, if the types being merged\r\nare int32 and native int, keeps the first type in order to\r\nconform to the ECMA standard. This fixed 8 tests.\r\n\r\nFor #797, if a switch has a selector whose type is not i32,\r\nfix up the types of the case values to match. This fixed\r\ntwo tests.","created_at":"2015-08-26T23:14:39Z","updated_at":"2015-08-27T01:05:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aa6fb4055baf8c01ef62c0564b0c3fddda8da093","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/llilc/pulls/800/commits","review_comments_url":"https://api.github.com/repos/dotnet/llilc/pulls/800/comments","review_comment_url":"https://api.github.com/repos/dotnet/llilc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/llilc/issues/800/comments","statuses_url":"https://api.github.com/repos/dotnet/llilc/statuses/74a1f26cca209ab325b512a715617ebea6a4d0f0","head":{"label":"richardlford:fix789and797","ref":"fix789and797","sha":"74a1f26cca209ab325b512a715617ebea6a4d0f0","user":{"login":"richardlford","id":6829071,"avatar_url":"https://avatars.githubusercontent.com/u/6829071?v=3","gravatar_id":"","url":"https://api.github.com/users/richardlford","html_url":"https://github.com/richardlford","followers_url":"https://api.github.com/users/richardlford/followers","following_url":"https://api.github.com/users/richardlford/following{/other_user}","gists_url":"https://api.github.com/users/richardlford/gists{/gist_id}","starred_url":"https://api.github.com/users/richardlford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardlford/subscriptions","organizations_url":"https://api.github.com/users/richardlford/orgs","repos_url":"https://api.github.com/users/richardlford/repos","events_url":"https://api.github.com/users/richardlford/events{/privacy}","received_events_url":"https://api.github.com/users/richardlford/received_events","type":"User","site_admin":false},"repo":{"id":33897059,"name":"llilc","full_name":"richardlford/llilc","owner":{"login":"richardlford","id":6829071,"avatar_url":"https://avatars.githubusercontent.com/u/6829071?v=3","gravatar_id":"","url":"https://api.github.com/users/richardlford","html_url":"https://github.com/richardlford","followers_url":"https://api.github.com/users/richardlford/followers","following_url":"https://api.github.com/users/richardlford/following{/other_user}","gists_url":"https://api.github.com/users/richardlford/gists{/gist_id}","starred_url":"https://api.github.com/users/richardlford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardlford/subscriptions","organizations_url":"https://api.github.com/users/richardlford/orgs","repos_url":"https://api.github.com/users/richardlford/repos","events_url":"https://api.github.com/users/richardlford/events{/privacy}","received_events_url":"https://api.github.com/users/richardlford/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/richardlford/llilc","description":"This repo contains LLILC, an LLVM based compiler for .NET Core. It includes a set of cross-platform .NET code generation tools that enables compilation of MSIL byte code to LLVM supported platforms.","fork":true,"url":"https://api.github.com/repos/richardlford/llilc","forks_url":"https://api.github.com/repos/richardlford/llilc/forks","keys_url":"https://api.github.com/repos/richardlford/llilc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/richardlford/llilc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/richardlford/llilc/teams","hooks_url":"https://api.github.com/repos/richardlford/llilc/hooks","issue_events_url":"https://api.github.com/repos/richardlford/llilc/issues/events{/number}","events_url":"https://api.github.com/repos/richardlford/llilc/events","assignees_url":"https://api.github.com/repos/richardlford/llilc/assignees{/user}","branches_url":"https://api.github.com/repos/richardlford/llilc/branches{/branch}","tags_url":"https://api.github.com/repos/richardlford/llilc/tags","blobs_url":"https://api.github.com/repos/richardlford/llilc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/richardlford/llilc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/richardlford/llilc/git/refs{/sha}","trees_url":"https://api.github.com/repos/richardlford/llilc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/richardlford/llilc/statuses/{sha}","languages_url":"https://api.github.com/repos/richardlford/llilc/languages","stargazers_url":"https://api.github.com/repos/richardlford/llilc/stargazers","contributors_url":"https://api.github.com/repos/richardlford/llilc/contributors","subscribers_url":"https://api.github.com/repos/richardlford/llilc/subscribers","subscription_url":"https://api.github.com/repos/richardlford/llilc/subscription","commits_url":"https://api.github.com/repos/richardlford/llilc/commits{/sha}","git_commits_url":"https://api.github.com/repos/richardlford/llilc/git/commits{/sha}","comments_url":"https://api.github.com/repos/richardlford/llilc/comments{/number}","issue_comment_url":"https://api.github.com/repos/richardlford/llilc/issues/comments{/number}","contents_url":"https://api.github.com/repos/richardlford/llilc/contents/{+path}","compare_url":"https://api.github.com/repos/richardlford/llilc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/richardlford/llilc/merges","archive_url":"https://api.github.com/repos/richardlford/llilc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/richardlford/llilc/downloads","issues_url":"https://api.github.com/repos/richardlford/llilc/issues{/number}","pulls_url":"https://api.github.com/repos/richardlford/llilc/pulls{/number}","milestones_url":"https://api.github.com/repos/richardlford/llilc/milestones{/number}","notifications_url":"https://api.github.com/repos/richardlford/llilc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/richardlford/llilc/labels{/name}","releases_url":"https://api.github.com/repos/richardlford/llilc/releases{/id}","created_at":"2015-04-13T22:17:19Z","updated_at":"2015-05-08T17:33:37Z","pushed_at":"2015-08-27T00:17:38Z","git_url":"git://github.com/richardlford/llilc.git","ssh_url":"git@github.com:richardlford/llilc.git","clone_url":"https://github.com/richardlford/llilc.git","svn_url":"https://github.com/richardlford/llilc","homepage":"","size":5519,"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":"dotnet:master","ref":"master","sha":"a390b61fe83edb7920c7552308fb6f26f946b0ca","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":30043131,"name":"llilc","full_name":"dotnet/llilc","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/llilc","description":"This repo contains LLILC, an LLVM based compiler for .NET Core. It includes a set of cross-platform .NET code generation tools that enables compilation of MSIL byte code to LLVM supported platforms.","fork":false,"url":"https://api.github.com/repos/dotnet/llilc","forks_url":"https://api.github.com/repos/dotnet/llilc/forks","keys_url":"https://api.github.com/repos/dotnet/llilc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/llilc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/llilc/teams","hooks_url":"https://api.github.com/repos/dotnet/llilc/hooks","issue_events_url":"https://api.github.com/repos/dotnet/llilc/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/llilc/events","assignees_url":"https://api.github.com/repos/dotnet/llilc/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/llilc/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/llilc/tags","blobs_url":"https://api.github.com/repos/dotnet/llilc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/llilc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/llilc/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/llilc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/llilc/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/llilc/languages","stargazers_url":"https://api.github.com/repos/dotnet/llilc/stargazers","contributors_url":"https://api.github.com/repos/dotnet/llilc/contributors","subscribers_url":"https://api.github.com/repos/dotnet/llilc/subscribers","subscription_url":"https://api.github.com/repos/dotnet/llilc/subscription","commits_url":"https://api.github.com/repos/dotnet/llilc/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/llilc/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/llilc/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/llilc/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/llilc/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/llilc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/llilc/merges","archive_url":"https://api.github.com/repos/dotnet/llilc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/llilc/downloads","issues_url":"https://api.github.com/repos/dotnet/llilc/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/llilc/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/llilc/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/llilc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/llilc/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/llilc/releases{/id}","created_at":"2015-01-29T21:52:01Z","updated_at":"2015-08-26T06:28:58Z","pushed_at":"2015-08-27T01:04:42Z","git_url":"git://github.com/dotnet/llilc.git","ssh_url":"git@github.com:dotnet/llilc.git","clone_url":"https://github.com/dotnet/llilc.git","svn_url":"https://github.com/dotnet/llilc","homepage":"","size":11756,"stargazers_count":805,"watchers_count":805,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":69,"mirror_url":null,"open_issues_count":154,"forks":69,"open_issues":154,"watchers":805,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/llilc/pulls/800"},"html":{"href":"https://github.com/dotnet/llilc/pull/800"},"issue":{"href":"https://api.github.com/repos/dotnet/llilc/issues/800"},"comments":{"href":"https://api.github.com/repos/dotnet/llilc/issues/800/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/llilc/pulls/800/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/llilc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/llilc/pulls/800/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/llilc/statuses/74a1f26cca209ab325b512a715617ebea6a4d0f0"}}}}