mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-22 11:40:05 +00:00
Only check def dominance of reachable uses
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/295
This commit is contained in:
parent
50707a1257
commit
621fa3961f
1
CHANGES
1
CHANGES
@ -13,6 +13,7 @@ v2016.2-dev 2016-07-19
|
||||
#279: validator: infinite loop when analyzing some degenerate control
|
||||
flow graphs
|
||||
#290: disassembler: never generate bare % for an identifier
|
||||
#295: validator: def-use dominance check should ignore unreachable uses
|
||||
|
||||
v2016.1 2016-07-19
|
||||
- Fix https://github.com/KhronosGroup/SPIRV-Tools/issues/261
|
||||
|
@ -2392,6 +2392,7 @@ spv_result_t CheckIdDefinitionDominateUse(const ValidationState_t& _) {
|
||||
// If the Id is defined within a block then make sure all references to
|
||||
// that Id appear in a blocks that are dominated by the defining block
|
||||
for (auto use : definition.second.uses()) {
|
||||
if (!use->reachable()) continue;
|
||||
if (use->dom_end() == find(use->dom_begin(), use->dom_end(), block)) {
|
||||
return _.diag(SPV_ERROR_INVALID_ID)
|
||||
<< "ID " << _.getIdName(definition.first)
|
||||
|
@ -1234,6 +1234,44 @@ TEST_F(ValidateSSA, DISABLED_PhiVariableDefMustComeFromBlockDominatingThePredece
|
||||
// TODO(dneto): Check for a good error message
|
||||
}
|
||||
|
||||
TEST_F(ValidateSSA, DominanceCheckIgnoresUsesInUnreachableBlocksDefInBlockGood) {
|
||||
string str = kHeader
|
||||
+ kBasicTypes +
|
||||
R"(
|
||||
%func = OpFunction %voidt None %vfunct
|
||||
%entry = OpLabel
|
||||
%def = OpCopyObject %boolt %false
|
||||
OpReturn
|
||||
|
||||
%unreach = OpLabel
|
||||
%use = OpCopyObject %boolt %def
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
CompileSuccessfully(str);
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()) << getDiagnosticString();
|
||||
}
|
||||
|
||||
TEST_F(ValidateSSA, DominanceCheckIgnoresUsesInUnreachableBlocksDefIsParamGood) {
|
||||
string str = kHeader + kBasicTypes +
|
||||
R"(
|
||||
%void_fn_int = OpTypeFunction %voidt %intt
|
||||
%func = OpFunction %voidt None %void_fn_int
|
||||
%int_param = OpFunctionParameter %intt
|
||||
%entry = OpLabel
|
||||
OpReturn
|
||||
|
||||
%unreach = OpLabel
|
||||
%use = OpCopyObject %intt %int_param
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
CompileSuccessfully(str);
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()) << getDiagnosticString();
|
||||
}
|
||||
|
||||
TEST_F(ValidateSSA, UseFunctionParameterFromOtherFunctionBad) {
|
||||
string str = kHeader +
|
||||
"OpName %first \"first\"\n"
|
||||
|
Loading…
Reference in New Issue
Block a user