{"action":"created","comment":{"url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/comments/91810907","pull_request_review_id":12324478,"id":91810907,"diff_hunk":"@@ -424,14 +424,63 @@ spv_result_t PerformCfgChecks(ValidationState_t& _) {\n       for (auto edge : postdom_edges) {\n         edge.first->SetImmediatePostDominator(edge.second);\n       }\n-      /// calculate back edges.\n+      /// Calculate back edges.\n       DepthFirstTraversal(\n           function.pseudo_entry_block(),\n           function\n               .AugmentedCFGSuccessorsFunctionIncludingHeaderToContinueEdge(),\n           ignore_block, ignore_block, [&](cbb_ptr from, cbb_ptr to) {\n             back_edges.emplace_back(from->id(), to->id());\n           });\n+\n+      // Perform a DepthFirstTraversal that ensures CFG nesting depth is valid.\n+      const int cfg_depth_limit = 1023;\n+      bool cfg_depth_limit_violated = false;\n+      int depth = 0;\n+      std::unordered_map<cbb_ptr, int> block_depth;\n+      DepthFirstTraversal(\n+          function.first_block(), function.AugmentedCFGSuccessorsFunction(),\n+          [&](cbb_ptr b) {\n+            // Header block of a loop.\n+            if (b->is_type(kBlockTypeLoop)) {\n+              // at this point we can set the depth for the merge block and\n+              // continue block of the loop.\n+              const auto& construct = function.FindConstructForEntryBlock(b);\n+              const auto& merge_block = construct.exit_block();\n+              // since it's a loop, the corresponding construct is just the\n+              // continue construct: A vector with 1 element.\n+              const auto& continue_construct =\n+                  construct.corresponding_constructs()[0];\n+              const auto& continue_block = continue_construct->entry_block();\n+              block_depth[b] = depth;\n+              block_depth[merge_block] = depth;\n+              block_depth[continue_block] = depth + 1;\n+              ++depth;\n+            } else if (b->is_type(kBlockTypeHeader)) {\n+              // Header block of a selection.\n+              const auto& construct = function.FindConstructForEntryBlock(b);\n+              const auto& merge_block = construct.exit_block();\n+              block_depth[b] = depth;\n+              block_depth[merge_block] = depth;\n+              ++depth;\n+            } else if (block_depth.find(b) == block_depth.end()) {\n+              block_depth[b] = depth;\n+            }","path":"source/validate_cfg.cpp","position":64,"original_position":64,"commit_id":"224d132ee98b88e9287a9056d0c553992b9fb2ff","original_commit_id":"224d132ee98b88e9287a9056d0c553992b9fb2ff","user":{"login":"ehsannas","id":3828215,"avatar_url":"https://avatars.githubusercontent.com/u/3828215?v=3","gravatar_id":"","url":"https://api.github.com/users/ehsannas","html_url":"https://github.com/ehsannas","followers_url":"https://api.github.com/users/ehsannas/followers","following_url":"https://api.github.com/users/ehsannas/following{/other_user}","gists_url":"https://api.github.com/users/ehsannas/gists{/gist_id}","starred_url":"https://api.github.com/users/ehsannas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehsannas/subscriptions","organizations_url":"https://api.github.com/users/ehsannas/orgs","repos_url":"https://api.github.com/users/ehsannas/repos","events_url":"https://api.github.com/users/ehsannas/events{/privacy}","received_events_url":"https://api.github.com/users/ehsannas/received_events","type":"User","site_admin":false},"body":"No apology needed. I'm glad \r\n\r\n> we would end up setting the depth of the remaining blocks in the continue construct (aside from the continue target) to 10 or more. That's a bug, I think.\r\n\r\nYou're right. There's a subtle bug here: I hadn't thought about the fact that continue blocks could be multiple levels deep. The depth of deeper levels of the continue block would be calculated incorrectly here.","created_at":"2016-12-09T22:49:11Z","updated_at":"2016-12-09T22:49:11Z","html_url":"https://github.com/KhronosGroup/SPIRV-Tools/pull/505#discussion_r91810907","pull_request_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/505","_links":{"self":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/comments/91810907"},"html":{"href":"https://github.com/KhronosGroup/SPIRV-Tools/pull/505#discussion_r91810907"},"pull_request":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/505"}}},"pull_request":{"url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/505","id":97366924,"html_url":"https://github.com/KhronosGroup/SPIRV-Tools/pull/505","diff_url":"https://github.com/KhronosGroup/SPIRV-Tools/pull/505.diff","patch_url":"https://github.com/KhronosGroup/SPIRV-Tools/pull/505.patch","issue_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues/505","number":505,"state":"open","locked":false,"title":"Validation code for Control Flow Nesting depth.","user":{"login":"ehsannas","id":3828215,"avatar_url":"https://avatars.githubusercontent.com/u/3828215?v=3","gravatar_id":"","url":"https://api.github.com/users/ehsannas","html_url":"https://github.com/ehsannas","followers_url":"https://api.github.com/users/ehsannas/followers","following_url":"https://api.github.com/users/ehsannas/following{/other_user}","gists_url":"https://api.github.com/users/ehsannas/gists{/gist_id}","starred_url":"https://api.github.com/users/ehsannas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehsannas/subscriptions","organizations_url":"https://api.github.com/users/ehsannas/orgs","repos_url":"https://api.github.com/users/ehsannas/repos","events_url":"https://api.github.com/users/ehsannas/events{/privacy}","received_events_url":"https://api.github.com/users/ehsannas/received_events","type":"User","site_admin":false},"body":"According to Universal Limits section (2.17) of SPIRV Spec, the\r\ncontrol-flow nesting depth may not exceed 1023.\r\n\r\nWe can check this by utilizing the existing DepthFirstTraversal code\r\nthat operates on the control-flow graph.\r\n\r\nAlso added 2 unit tests.","created_at":"2016-12-09T19:34:17Z","updated_at":"2016-12-09T22:49:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3345dba380fba8f3b2acaa701a9cad9a7805e801","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/505/commits","review_comments_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/505/comments","review_comment_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues/505/comments","statuses_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/statuses/224d132ee98b88e9287a9056d0c553992b9fb2ff","head":{"label":"ehsannas:cfdepth_limit","ref":"cfdepth_limit","sha":"224d132ee98b88e9287a9056d0c553992b9fb2ff","user":{"login":"ehsannas","id":3828215,"avatar_url":"https://avatars.githubusercontent.com/u/3828215?v=3","gravatar_id":"","url":"https://api.github.com/users/ehsannas","html_url":"https://github.com/ehsannas","followers_url":"https://api.github.com/users/ehsannas/followers","following_url":"https://api.github.com/users/ehsannas/following{/other_user}","gists_url":"https://api.github.com/users/ehsannas/gists{/gist_id}","starred_url":"https://api.github.com/users/ehsannas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehsannas/subscriptions","organizations_url":"https://api.github.com/users/ehsannas/orgs","repos_url":"https://api.github.com/users/ehsannas/repos","events_url":"https://api.github.com/users/ehsannas/events{/privacy}","received_events_url":"https://api.github.com/users/ehsannas/received_events","type":"User","site_admin":false},"repo":{"id":72889860,"name":"SPIRV-Tools","full_name":"ehsannas/SPIRV-Tools","owner":{"login":"ehsannas","id":3828215,"avatar_url":"https://avatars.githubusercontent.com/u/3828215?v=3","gravatar_id":"","url":"https://api.github.com/users/ehsannas","html_url":"https://github.com/ehsannas","followers_url":"https://api.github.com/users/ehsannas/followers","following_url":"https://api.github.com/users/ehsannas/following{/other_user}","gists_url":"https://api.github.com/users/ehsannas/gists{/gist_id}","starred_url":"https://api.github.com/users/ehsannas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehsannas/subscriptions","organizations_url":"https://api.github.com/users/ehsannas/orgs","repos_url":"https://api.github.com/users/ehsannas/repos","events_url":"https://api.github.com/users/ehsannas/events{/privacy}","received_events_url":"https://api.github.com/users/ehsannas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ehsannas/SPIRV-Tools","description":null,"fork":true,"url":"https://api.github.com/repos/ehsannas/SPIRV-Tools","forks_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/forks","keys_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/teams","hooks_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/hooks","issue_events_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/issues/events{/number}","events_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/events","assignees_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/assignees{/user}","branches_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/branches{/branch}","tags_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/tags","blobs_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/statuses/{sha}","languages_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/languages","stargazers_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/stargazers","contributors_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/contributors","subscribers_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/subscribers","subscription_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/subscription","commits_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/contents/{+path}","compare_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/merges","archive_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/downloads","issues_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/issues{/number}","pulls_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/pulls{/number}","milestones_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/milestones{/number}","notifications_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/labels{/name}","releases_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/releases{/id}","deployments_url":"https://api.github.com/repos/ehsannas/SPIRV-Tools/deployments","created_at":"2016-11-04T22:27:17Z","updated_at":"2016-11-04T22:27:19Z","pushed_at":"2016-12-09T20:15:45Z","git_url":"git://github.com/ehsannas/SPIRV-Tools.git","ssh_url":"git@github.com:ehsannas/SPIRV-Tools.git","clone_url":"https://github.com/ehsannas/SPIRV-Tools.git","svn_url":"https://github.com/ehsannas/SPIRV-Tools","homepage":null,"size":2882,"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":"KhronosGroup:master","ref":"master","sha":"945e9fc4b477ee55d2262249e5d1d886aa6ba679","user":{"login":"KhronosGroup","id":1608701,"avatar_url":"https://avatars.githubusercontent.com/u/1608701?v=3","gravatar_id":"","url":"https://api.github.com/users/KhronosGroup","html_url":"https://github.com/KhronosGroup","followers_url":"https://api.github.com/users/KhronosGroup/followers","following_url":"https://api.github.com/users/KhronosGroup/following{/other_user}","gists_url":"https://api.github.com/users/KhronosGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/KhronosGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KhronosGroup/subscriptions","organizations_url":"https://api.github.com/users/KhronosGroup/orgs","repos_url":"https://api.github.com/users/KhronosGroup/repos","events_url":"https://api.github.com/users/KhronosGroup/events{/privacy}","received_events_url":"https://api.github.com/users/KhronosGroup/received_events","type":"Organization","site_admin":false},"repo":{"id":45981801,"name":"SPIRV-Tools","full_name":"KhronosGroup/SPIRV-Tools","owner":{"login":"KhronosGroup","id":1608701,"avatar_url":"https://avatars.githubusercontent.com/u/1608701?v=3","gravatar_id":"","url":"https://api.github.com/users/KhronosGroup","html_url":"https://github.com/KhronosGroup","followers_url":"https://api.github.com/users/KhronosGroup/followers","following_url":"https://api.github.com/users/KhronosGroup/following{/other_user}","gists_url":"https://api.github.com/users/KhronosGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/KhronosGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KhronosGroup/subscriptions","organizations_url":"https://api.github.com/users/KhronosGroup/orgs","repos_url":"https://api.github.com/users/KhronosGroup/repos","events_url":"https://api.github.com/users/KhronosGroup/events{/privacy}","received_events_url":"https://api.github.com/users/KhronosGroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/KhronosGroup/SPIRV-Tools","description":null,"fork":false,"url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools","forks_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/forks","keys_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/teams","hooks_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/hooks","issue_events_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues/events{/number}","events_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/events","assignees_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/assignees{/user}","branches_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/branches{/branch}","tags_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/tags","blobs_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/statuses/{sha}","languages_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/languages","stargazers_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/stargazers","contributors_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/contributors","subscribers_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/subscribers","subscription_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/subscription","commits_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/contents/{+path}","compare_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/merges","archive_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/downloads","issues_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues{/number}","pulls_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls{/number}","milestones_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/milestones{/number}","notifications_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/labels{/name}","releases_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/releases{/id}","deployments_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/deployments","created_at":"2015-11-11T12:56:25Z","updated_at":"2016-12-07T23:08:54Z","pushed_at":"2016-12-09T20:15:46Z","git_url":"git://github.com/KhronosGroup/SPIRV-Tools.git","ssh_url":"git@github.com:KhronosGroup/SPIRV-Tools.git","clone_url":"https://github.com/KhronosGroup/SPIRV-Tools.git","svn_url":"https://github.com/KhronosGroup/SPIRV-Tools","homepage":null,"size":3636,"stargazers_count":151,"watchers_count":151,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":47,"mirror_url":null,"open_issues_count":43,"forks":47,"open_issues":43,"watchers":151,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/505"},"html":{"href":"https://github.com/KhronosGroup/SPIRV-Tools/pull/505"},"issue":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues/505"},"comments":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues/505/comments"},"review_comments":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/505/comments"},"review_comment":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/505/commits"},"statuses":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/statuses/224d132ee98b88e9287a9056d0c553992b9fb2ff"}}}}
{"actor":{"display_login":"ehsannas"}}