mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2025-01-13 01:40:14 +00:00
Fix broken recurison validation tests (#2174)
This fixes tests that were broken by adding in validation of the order of function definitions.
This commit is contained in:
parent
378b7f3a29
commit
d9a972210f
@ -57,19 +57,19 @@ OpExecutionMode %1 OriginUpperLeft
|
|||||||
%float = OpTypeFloat 32
|
%float = OpTypeFloat 32
|
||||||
%_struct_6 = OpTypeStruct %float %float
|
%_struct_6 = OpTypeStruct %float %float
|
||||||
%7 = OpTypeFunction %_struct_6
|
%7 = OpTypeFunction %_struct_6
|
||||||
%1 = OpFunction %void Pure|Const %4
|
%12 = OpFunction %_struct_6 None %7
|
||||||
%8 = OpLabel
|
%13 = OpLabel
|
||||||
%2 = OpFunctionCall %_struct_6 %9
|
OpUnreachable
|
||||||
OpKill
|
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%9 = OpFunction %_struct_6 None %7
|
%9 = OpFunction %_struct_6 None %7
|
||||||
%10 = OpLabel
|
%10 = OpLabel
|
||||||
%11 = OpFunctionCall %_struct_6 %12
|
%11 = OpFunctionCall %_struct_6 %12
|
||||||
OpUnreachable
|
OpUnreachable
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%12 = OpFunction %_struct_6 None %7
|
%1 = OpFunction %void Pure|Const %4
|
||||||
%13 = OpLabel
|
%8 = OpLabel
|
||||||
OpUnreachable
|
%2 = OpFunctionCall %_struct_6 %9
|
||||||
|
OpKill
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
)";
|
)";
|
||||||
|
|
||||||
@ -81,14 +81,14 @@ OpExecutionMode %1 OriginUpperLeft
|
|||||||
%float = OpTypeFloat 32
|
%float = OpTypeFloat 32
|
||||||
%_struct_6 = OpTypeStruct %float %float
|
%_struct_6 = OpTypeStruct %float %float
|
||||||
%7 = OpTypeFunction %_struct_6
|
%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
|
%9 = OpFunction %_struct_6 None %7
|
||||||
%10 = OpLabel
|
%10 = OpLabel
|
||||||
%11 = OpFunctionCall %_struct_6 %9
|
%11 = OpFunctionCall %_struct_6 %9
|
||||||
|
OpKill
|
||||||
|
OpFunctionEnd
|
||||||
|
%1 = OpFunction %void Pure|Const %4
|
||||||
|
%8 = OpLabel
|
||||||
|
%2 = OpFunctionCall %_struct_6 %9
|
||||||
OpUnreachable
|
OpUnreachable
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
)";
|
)";
|
||||||
@ -101,11 +101,6 @@ OpExecutionMode %1 OriginUpperLeft
|
|||||||
%float = OpTypeFloat 32
|
%float = OpTypeFloat 32
|
||||||
%_struct_6 = OpTypeStruct %float %float
|
%_struct_6 = OpTypeStruct %float %float
|
||||||
%7 = OpTypeFunction %_struct_6
|
%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
|
%9 = OpFunction %_struct_6 None %7
|
||||||
%10 = OpLabel
|
%10 = OpLabel
|
||||||
%11 = OpFunctionCall %_struct_6 %12
|
%11 = OpFunctionCall %_struct_6 %12
|
||||||
@ -116,6 +111,11 @@ OpFunctionEnd
|
|||||||
%14 = OpFunctionCall %_struct_6 %9
|
%14 = OpFunctionCall %_struct_6 %9
|
||||||
OpUnreachable
|
OpUnreachable
|
||||||
OpFunctionEnd
|
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.
|
// Tests that the instruction count in ValidationState is correct.
|
||||||
@ -292,15 +292,18 @@ TEST_F(ValidationStateTest, CheckVulkanIndirectlyRecursiveBodyBad) {
|
|||||||
" %1 = OpFunction %void Pure|Const %3\n"));
|
" %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) {
|
TEST_F(ValidationStateTest, CheckWebGPUIndirectlyRecursiveBodyBad) {
|
||||||
std::string spirv =
|
std::string spirv =
|
||||||
std::string(kVulkanMemoryHeader) + kIndirectlyRecursiveBody;
|
std::string(kVulkanMemoryHeader) + kIndirectlyRecursiveBody;
|
||||||
CompileSuccessfully(spirv, SPV_ENV_WEBGPU_0);
|
CompileSuccessfully(spirv, SPV_ENV_WEBGPU_0);
|
||||||
EXPECT_EQ(SPV_ERROR_INVALID_BINARY,
|
EXPECT_EQ(SPV_ERROR_INVALID_LAYOUT,
|
||||||
ValidateAndRetrieveValidationState(SPV_ENV_WEBGPU_0));
|
ValidateAndRetrieveValidationState(SPV_ENV_WEBGPU_0));
|
||||||
EXPECT_THAT(getDiagnosticString(),
|
EXPECT_THAT(getDiagnosticString(),
|
||||||
HasSubstr("Entry points may not have a call graph with cycles.\n "
|
HasSubstr("For WebGPU, functions need to be defined before being "
|
||||||
" %1 = OpFunction %void Pure|Const %3\n"));
|
"called.\n %9 = OpFunctionCall %_struct_5 %10\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user