File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -839,6 +839,9 @@ spv_result_t StructuredControlFlowChecks(
839
839
const auto * continue_target = next_inst.block ();
840
840
if (header->id () != continue_id) {
841
841
for (auto pred : *continue_target->predecessors ()) {
842
+ if (!pred->structurally_reachable ()) {
843
+ continue ;
844
+ }
842
845
// Ignore back-edges from within the continue construct.
843
846
bool is_back_edge = false ;
844
847
for (auto back_edge : back_edges) {
Original file line number Diff line number Diff line change @@ -5118,6 +5118,43 @@ OpFunctionEnd
5118
5118
EXPECT_EQ (SPV_SUCCESS, ValidateInstructions ());
5119
5119
}
5120
5120
5121
+ TEST_F (ValidateCFG, StructurallyUnreachableContinuePredecessor) {
5122
+ const std::string text = R"(
5123
+ OpCapability Shader
5124
+ OpMemoryModel Logical GLSL450
5125
+ OpEntryPoint Fragment %main "main"
5126
+ OpExecutionMode %main OriginUpperLeft
5127
+ OpSource ESSL 310
5128
+ OpName %main "main"
5129
+ %void = OpTypeVoid
5130
+ %3 = OpTypeFunction %void
5131
+ %int = OpTypeInt 32 1
5132
+ %int_1 = OpConstant %int 1
5133
+ %int_n7 = OpConstant %int -7
5134
+ %bool = OpTypeBool
5135
+ %main = OpFunction %void None %3
5136
+ %8 = OpLabel
5137
+ OpBranch %9
5138
+ %9 = OpLabel
5139
+ %10 = OpPhi %int %int_1 %8 %int_n7 %15
5140
+ %12 = OpSGreaterThan %bool %10 %int_n7
5141
+ OpLoopMerge %13 %15 None
5142
+ OpBranchConditional %12 %14 %13
5143
+ %14 = OpLabel
5144
+ OpBranch %15
5145
+ %15 = OpLabel
5146
+ OpBranch %9
5147
+ %17 = OpLabel
5148
+ OpBranch %15
5149
+ %13 = OpLabel
5150
+ OpReturn
5151
+ OpFunctionEnd
5152
+ )" ;
5153
+
5154
+ CompileSuccessfully (text);
5155
+ EXPECT_EQ (SPV_SUCCESS, ValidateInstructions ());
5156
+ }
5157
+
5121
5158
} // namespace
5122
5159
} // namespace val
5123
5160
} // namespace spvtools
You can’t perform that action at this time.
0 commit comments