mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-23 12:10:06 +00:00
Set wrapped kill basic block's parent (#3269)
Fixes #3268 * Set the parent of the basic block for the wrapper function * Add a test
This commit is contained in:
parent
c37c94929b
commit
f20c0d7971
@ -147,6 +147,7 @@ uint32_t WrapOpKill::GetOpKillFuncId() {
|
|||||||
bb->AddInstruction(std::move(kill_inst));
|
bb->AddInstruction(std::move(kill_inst));
|
||||||
|
|
||||||
// Add the bb to the function
|
// Add the bb to the function
|
||||||
|
bb->SetParent(opkill_function_.get());
|
||||||
opkill_function_->AddBasicBlock(std::move(bb));
|
opkill_function_->AddBasicBlock(std::move(bb));
|
||||||
|
|
||||||
// Add the function to the module.
|
// Add the function to the module.
|
||||||
|
@ -513,6 +513,40 @@ OpFunctionEnd
|
|||||||
EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(WrapOpKillTest, SetParentBlock) {
|
||||||
|
const std::string text = R"(
|
||||||
|
OpCapability Shader
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Fragment %main "main"
|
||||||
|
OpExecutionMode %main OriginUpperLeft
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%bool = OpTypeBool
|
||||||
|
%undef = OpUndef %bool
|
||||||
|
%void_fn = OpTypeFunction %void
|
||||||
|
%main = OpFunction %void None %void_fn
|
||||||
|
%entry = OpLabel
|
||||||
|
OpBranch %loop
|
||||||
|
%loop = OpLabel
|
||||||
|
OpLoopMerge %merge %continue None
|
||||||
|
OpBranchConditional %undef %merge %continue
|
||||||
|
%continue = OpLabel
|
||||||
|
%call = OpFunctionCall %void %kill_func
|
||||||
|
OpBranch %loop
|
||||||
|
%merge = OpLabel
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%kill_func = OpFunction %void None %void_fn
|
||||||
|
%kill_entry = OpLabel
|
||||||
|
OpKill
|
||||||
|
OpFunctionEnd
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto result = SinglePassRunToBinary<WrapOpKill>(text, true);
|
||||||
|
EXPECT_EQ(Pass::Status::SuccessWithChange, std::get<1>(result));
|
||||||
|
result = SinglePassRunToBinary<WrapOpKill>(text, true);
|
||||||
|
EXPECT_EQ(Pass::Status::SuccessWithChange, std::get<1>(result));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace opt
|
} // namespace opt
|
||||||
} // namespace spvtools
|
} // namespace spvtools
|
||||||
|
Loading…
Reference in New Issue
Block a user