Skip to content

Commit

Permalink
Fix broken recurison validation tests (KhronosGroup#2174)
Browse files Browse the repository at this point in the history
This fixes tests that were broken by adding in validation of the order
of function definitions.
  • Loading branch information
zoddicus authored Dec 5, 2018
1 parent 378b7f3 commit d9a9722
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions test/val/val_validation_state_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ OpExecutionMode %1 OriginUpperLeft
%float = OpTypeFloat 32
%_struct_6 = OpTypeStruct %float %float
%7 = OpTypeFunction %_struct_6
%1 = OpFunction %void Pure|Const %4
%8 = OpLabel
%2 = OpFunctionCall %_struct_6 %9
OpKill
%12 = OpFunction %_struct_6 None %7
%13 = OpLabel
OpUnreachable
OpFunctionEnd
%9 = OpFunction %_struct_6 None %7
%10 = OpLabel
%11 = OpFunctionCall %_struct_6 %12
OpUnreachable
OpFunctionEnd
%12 = OpFunction %_struct_6 None %7
%13 = OpLabel
OpUnreachable
%1 = OpFunction %void Pure|Const %4
%8 = OpLabel
%2 = OpFunctionCall %_struct_6 %9
OpKill
OpFunctionEnd
)";

Expand All @@ -81,14 +81,14 @@ OpExecutionMode %1 OriginUpperLeft
%float = OpTypeFloat 32
%_struct_6 = OpTypeStruct %float %float
%7 = OpTypeFunction %_struct_6
%1 = OpFunction %void Pure|Const %4
%8 = OpLabel
%2 = OpFunctionCall %_struct_6 %9
OpKill
OpFunctionEnd
%9 = OpFunction %_struct_6 None %7
%10 = OpLabel
%11 = OpFunctionCall %_struct_6 %9
OpKill
OpFunctionEnd
%1 = OpFunction %void Pure|Const %4
%8 = OpLabel
%2 = OpFunctionCall %_struct_6 %9
OpUnreachable
OpFunctionEnd
)";
Expand All @@ -101,11 +101,6 @@ OpExecutionMode %1 OriginUpperLeft
%float = OpTypeFloat 32
%_struct_6 = OpTypeStruct %float %float
%7 = OpTypeFunction %_struct_6
%1 = OpFunction %void Pure|Const %4
%8 = OpLabel
%2 = OpFunctionCall %_struct_6 %9
OpKill
OpFunctionEnd
%9 = OpFunction %_struct_6 None %7
%10 = OpLabel
%11 = OpFunctionCall %_struct_6 %12
Expand All @@ -116,6 +111,11 @@ OpFunctionEnd
%14 = OpFunctionCall %_struct_6 %9
OpUnreachable
OpFunctionEnd
%1 = OpFunction %void Pure|Const %4
%8 = OpLabel
%2 = OpFunctionCall %_struct_6 %9
OpKill
OpFunctionEnd
)";

// Tests that the instruction count in ValidationState is correct.
Expand Down Expand Up @@ -292,15 +292,18 @@ TEST_F(ValidationStateTest, CheckVulkanIndirectlyRecursiveBodyBad) {
" %1 = OpFunction %void Pure|Const %3\n"));
}

// Indirectly recursive functions are caught by the function definition layout
// rules, because they cause a situation where there are 2 functions that have
// to be before each other, and layout is checked earlier.
TEST_F(ValidationStateTest, CheckWebGPUIndirectlyRecursiveBodyBad) {
std::string spirv =
std::string(kVulkanMemoryHeader) + kIndirectlyRecursiveBody;
CompileSuccessfully(spirv, SPV_ENV_WEBGPU_0);
EXPECT_EQ(SPV_ERROR_INVALID_BINARY,
EXPECT_EQ(SPV_ERROR_INVALID_LAYOUT,
ValidateAndRetrieveValidationState(SPV_ENV_WEBGPU_0));
EXPECT_THAT(getDiagnosticString(),
HasSubstr("Entry points may not have a call graph with cycles.\n "
" %1 = OpFunction %void Pure|Const %3\n"));
HasSubstr("For WebGPU, functions need to be defined before being "
"called.\n %9 = OpFunctionCall %_struct_5 %10\n"));
}

} // namespace
Expand Down

0 comments on commit d9a9722

Please sign in to comment.