[spirv-reader] Test block order with Kill, Unreachable

Bug: tint:3
Change-Id: Ic8627ca3449ddc7f6abf248b0a461cfbafe77819
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20041
Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
David Neto 2020-04-21 17:44:44 +00:00
parent 571eea5a1a
commit 6235caaae4
1 changed files with 44 additions and 0 deletions

View File

@ -79,6 +79,50 @@ TEST_F(SpvParserTest, ComputeBlockOrder_IgnoreStaticalyUnreachable) {
EXPECT_THAT(fe.rspo(), ElementsAre(10, 20)); EXPECT_THAT(fe.rspo(), ElementsAre(10, 20));
} }
TEST_F(SpvParserTest, ComputeBlockOrder_KillIsDeadEnd) {
auto* p = parser(test::Assemble(CommonTypes() + R"(
%100 = OpFunction %void None %voidfn
%10 = OpLabel
OpBranch %20
%15 = OpLabel ; statically dead
OpReturn
%20 = OpLabel
OpKill ; Kill doesn't lead anywhere
OpFunctionEnd
)"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
FunctionEmitter fe(p, *spirv_function(100));
fe.ComputeBlockOrderAndPositions();
EXPECT_THAT(fe.rspo(), ElementsAre(10, 20));
}
TEST_F(SpvParserTest, ComputeBlockOrder_UnreachableIsDeadEnd) {
auto* p = parser(test::Assemble(CommonTypes() + R"(
%100 = OpFunction %void None %voidfn
%10 = OpLabel
OpBranch %20
%15 = OpLabel ; statically dead
OpReturn
%20 = OpLabel
OpUnreachable ; Unreachable doesn't lead anywhere
OpFunctionEnd
)"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
FunctionEmitter fe(p, *spirv_function(100));
fe.ComputeBlockOrderAndPositions();
EXPECT_THAT(fe.rspo(), ElementsAre(10, 20));
}
TEST_F(SpvParserTest, ComputeBlockOrder_ReorderSequence) { TEST_F(SpvParserTest, ComputeBlockOrder_ReorderSequence) {
auto* p = parser(test::Assemble(CommonTypes() + R"( auto* p = parser(test::Assemble(CommonTypes() + R"(
%100 = OpFunction %void None %voidfn %100 = OpFunction %void None %voidfn