123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558 |
- // Copyright (c) 2019 Google LLC
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- #include <string>
- #include "gmock/gmock.h"
- #include "test/opt/assembly_builder.h"
- #include "test/opt/pass_fixture.h"
- #include "test/opt/pass_utils.h"
- namespace spvtools {
- namespace opt {
- namespace {
- using CodeSinkTest = PassTest<::testing::Test>;
- TEST_F(CodeSinkTest, MoveToNextBlock) {
- const std::string text = R"(
- ;CHECK: OpFunction
- ;CHECK: OpLabel
- ;CHECK: OpLabel
- ;CHECK: [[ac:%\w+]] = OpAccessChain
- ;CHECK: [[ld:%\w+]] = OpLoad %uint [[ac]]
- ;CHECK: OpCopyObject %uint [[ld]]
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- %void = OpTypeVoid
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %_arr_uint_uint_4 = OpTypeArray %uint %uint_4
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %9 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %10 = OpTypeFunction %void
- %1 = OpFunction %void None %10
- %11 = OpLabel
- %12 = OpAccessChain %_ptr_Uniform_uint %9 %uint_0
- %13 = OpLoad %uint %12
- OpBranch %14
- %14 = OpLabel
- %15 = OpCopyObject %uint %13
- OpReturn
- OpFunctionEnd
- )";
- SinglePassRunAndMatch<CodeSinkingPass>(text, true);
- }
- TEST_F(CodeSinkTest, MovePastSelection) {
- const std::string text = R"(
- ;CHECK: OpFunction
- ;CHECK: OpLabel
- ;CHECK: OpSelectionMerge [[merge_bb:%\w+]]
- ;CHECK: [[merge_bb]] = OpLabel
- ;CHECK: [[ac:%\w+]] = OpAccessChain
- ;CHECK: [[ld:%\w+]] = OpLoad %uint [[ac]]
- ;CHECK: OpCopyObject %uint [[ld]]
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %_arr_uint_uint_4 = OpTypeArray %uint %uint_4
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %11 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %12 = OpTypeFunction %void
- %1 = OpFunction %void None %12
- %13 = OpLabel
- %14 = OpAccessChain %_ptr_Uniform_uint %11 %uint_0
- %15 = OpLoad %uint %14
- OpSelectionMerge %16 None
- OpBranchConditional %true %17 %16
- %17 = OpLabel
- OpBranch %16
- %16 = OpLabel
- %18 = OpCopyObject %uint %15
- OpReturn
- OpFunctionEnd
- )";
- SinglePassRunAndMatch<CodeSinkingPass>(text, true);
- }
- TEST_F(CodeSinkTest, MoveIntoSelection) {
- const std::string text = R"(
- ;CHECK: OpFunction
- ;CHECK: OpLabel
- ;CHECK: OpSelectionMerge [[merge_bb:%\w+]]
- ;CHECK-NEXT: OpBranchConditional %true [[bb:%\w+]] [[merge_bb]]
- ;CHECK: [[bb]] = OpLabel
- ;CHECK-NEXT: [[ac:%\w+]] = OpAccessChain
- ;CHECK-NEXT: [[ld:%\w+]] = OpLoad %uint [[ac]]
- ;CHECK-NEXT: OpCopyObject %uint [[ld]]
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %_arr_uint_uint_4 = OpTypeArray %uint %uint_4
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %11 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %12 = OpTypeFunction %void
- %1 = OpFunction %void None %12
- %13 = OpLabel
- %14 = OpAccessChain %_ptr_Uniform_uint %11 %uint_0
- %15 = OpLoad %uint %14
- OpSelectionMerge %16 None
- OpBranchConditional %true %17 %16
- %17 = OpLabel
- %18 = OpCopyObject %uint %15
- OpBranch %16
- %16 = OpLabel
- OpReturn
- OpFunctionEnd
- )";
- SinglePassRunAndMatch<CodeSinkingPass>(text, true);
- }
- TEST_F(CodeSinkTest, LeaveBeforeSelection) {
- const std::string text = R"(
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %_arr_uint_uint_4 = OpTypeArray %uint %uint_4
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %11 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %12 = OpTypeFunction %void
- %1 = OpFunction %void None %12
- %13 = OpLabel
- %14 = OpAccessChain %_ptr_Uniform_uint %11 %uint_0
- %15 = OpLoad %uint %14
- OpSelectionMerge %16 None
- OpBranchConditional %true %17 %20
- %20 = OpLabel
- OpBranch %16
- %17 = OpLabel
- %18 = OpCopyObject %uint %15
- OpBranch %16
- %16 = OpLabel
- %19 = OpCopyObject %uint %15
- OpReturn
- OpFunctionEnd
- )";
- auto result = SinglePassRunAndDisassemble<CodeSinkingPass>(
- text, /* skip_nop = */ true, /* do_validation = */ true);
- EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
- }
- TEST_F(CodeSinkTest, LeaveAloneUseInSameBlock) {
- const std::string text = R"(
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %_arr_uint_uint_4 = OpTypeArray %uint %uint_4
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %11 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %12 = OpTypeFunction %void
- %1 = OpFunction %void None %12
- %13 = OpLabel
- %14 = OpAccessChain %_ptr_Uniform_uint %11 %uint_0
- %15 = OpLoad %uint %14
- %cond = OpIEqual %bool %15 %uint_0
- OpSelectionMerge %16 None
- OpBranchConditional %cond %17 %16
- %17 = OpLabel
- OpBranch %16
- %16 = OpLabel
- %19 = OpCopyObject %uint %15
- OpReturn
- OpFunctionEnd
- )";
- auto result = SinglePassRunAndDisassemble<CodeSinkingPass>(
- text, /* skip_nop = */ true, /* do_validation = */ true);
- EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
- }
- TEST_F(CodeSinkTest, DontMoveIntoLoop) {
- const std::string text = R"(
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %_arr_uint_uint_4 = OpTypeArray %uint %uint_4
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %11 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %12 = OpTypeFunction %void
- %1 = OpFunction %void None %12
- %13 = OpLabel
- %14 = OpAccessChain %_ptr_Uniform_uint %11 %uint_0
- %15 = OpLoad %uint %14
- OpBranch %17
- %17 = OpLabel
- OpLoopMerge %merge %cont None
- OpBranch %cont
- %cont = OpLabel
- %cond = OpIEqual %bool %15 %uint_0
- OpBranchConditional %cond %merge %17
- %merge = OpLabel
- OpReturn
- OpFunctionEnd
- )";
- auto result = SinglePassRunAndDisassemble<CodeSinkingPass>(
- text, /* skip_nop = */ true, /* do_validation = */ true);
- EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
- }
- TEST_F(CodeSinkTest, DontMoveIntoLoop2) {
- const std::string text = R"(
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %_arr_uint_uint_4 = OpTypeArray %uint %uint_4
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %11 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %12 = OpTypeFunction %void
- %1 = OpFunction %void None %12
- %13 = OpLabel
- %14 = OpAccessChain %_ptr_Uniform_uint %11 %uint_0
- %15 = OpLoad %uint %14
- OpSelectionMerge %16 None
- OpBranchConditional %true %17 %16
- %17 = OpLabel
- OpLoopMerge %merge %cont None
- OpBranch %cont
- %cont = OpLabel
- %cond = OpIEqual %bool %15 %uint_0
- OpBranchConditional %cond %merge %17
- %merge = OpLabel
- OpBranch %16
- %16 = OpLabel
- OpReturn
- OpFunctionEnd
- )";
- auto result = SinglePassRunAndDisassemble<CodeSinkingPass>(
- text, /* skip_nop = */ true, /* do_validation = */ true);
- EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
- }
- TEST_F(CodeSinkTest, DontMoveSelectionUsedInBothSides) {
- const std::string text = R"(
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %_arr_uint_uint_4 = OpTypeArray %uint %uint_4
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %11 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %12 = OpTypeFunction %void
- %1 = OpFunction %void None %12
- %13 = OpLabel
- %14 = OpAccessChain %_ptr_Uniform_uint %11 %uint_0
- %15 = OpLoad %uint %14
- OpSelectionMerge %16 None
- OpBranchConditional %true %17 %20
- %20 = OpLabel
- %19 = OpCopyObject %uint %15
- OpBranch %16
- %17 = OpLabel
- %18 = OpCopyObject %uint %15
- OpBranch %16
- %16 = OpLabel
- OpReturn
- OpFunctionEnd
- )";
- auto result = SinglePassRunAndDisassemble<CodeSinkingPass>(
- text, /* skip_nop = */ true, /* do_validation = */ true);
- EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
- }
- TEST_F(CodeSinkTest, DontMoveBecauseOfStore) {
- const std::string text = R"(
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %_arr_uint_uint_4 = OpTypeArray %uint %uint_4
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %11 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %12 = OpTypeFunction %void
- %1 = OpFunction %void None %12
- %13 = OpLabel
- %14 = OpAccessChain %_ptr_Uniform_uint %11 %uint_0
- %15 = OpLoad %uint %14
- OpStore %14 %15
- OpSelectionMerge %16 None
- OpBranchConditional %true %17 %20
- %20 = OpLabel
- OpBranch %16
- %17 = OpLabel
- %18 = OpCopyObject %uint %15
- OpBranch %16
- %16 = OpLabel
- OpReturn
- OpFunctionEnd
- )";
- auto result = SinglePassRunAndDisassemble<CodeSinkingPass>(
- text, /* skip_nop = */ true, /* do_validation = */ true);
- EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
- }
- TEST_F(CodeSinkTest, MoveReadOnlyLoadWithSync) {
- const std::string text = R"(
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %mem_semantics = OpConstant %uint 0x42 ; Uniform memeory arquire
- %_arr_uint_uint_4 = OpTypeArray %uint %uint_4
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %11 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %12 = OpTypeFunction %void
- %1 = OpFunction %void None %12
- %13 = OpLabel
- %14 = OpAccessChain %_ptr_Uniform_uint %11 %uint_0
- %15 = OpLoad %uint %14
- OpMemoryBarrier %uint_4 %mem_semantics
- OpSelectionMerge %16 None
- OpBranchConditional %true %17 %20
- %20 = OpLabel
- OpBranch %16
- %17 = OpLabel
- %18 = OpCopyObject %uint %15
- OpBranch %16
- %16 = OpLabel
- OpReturn
- OpFunctionEnd
- )";
- auto result = SinglePassRunAndDisassemble<CodeSinkingPass>(
- text, /* skip_nop = */ true, /* do_validation = */ true);
- EXPECT_EQ(Pass::Status::SuccessWithChange, std::get<1>(result));
- }
- TEST_F(CodeSinkTest, DontMoveBecauseOfSync) {
- const std::string text = R"(
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- OpDecorate %_arr_uint_uint_4 BufferBlock
- OpMemberDecorate %_arr_uint_uint_4 0 Offset 0
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %mem_semantics = OpConstant %uint 0x42 ; Uniform memeory arquire
- %_arr_uint_uint_4 = OpTypeStruct %uint
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %11 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %12 = OpTypeFunction %void
- %1 = OpFunction %void None %12
- %13 = OpLabel
- %14 = OpAccessChain %_ptr_Uniform_uint %11 %uint_0
- %15 = OpLoad %uint %14
- OpMemoryBarrier %uint_4 %mem_semantics
- OpSelectionMerge %16 None
- OpBranchConditional %true %17 %20
- %20 = OpLabel
- OpBranch %16
- %17 = OpLabel
- %18 = OpCopyObject %uint %15
- OpBranch %16
- %16 = OpLabel
- OpReturn
- OpFunctionEnd
- )";
- auto result = SinglePassRunAndDisassemble<CodeSinkingPass>(
- text, /* skip_nop = */ true, /* do_validation = */ true);
- EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
- }
- TEST_F(CodeSinkTest, DontMoveBecauseOfAtomicWithSync) {
- const std::string text = R"(
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- OpDecorate %_arr_uint_uint_4 BufferBlock
- OpMemberDecorate %_arr_uint_uint_4 0 Offset 0
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %mem_semantics = OpConstant %uint 0x42 ; Uniform memeory arquire
- %_arr_uint_uint_4 = OpTypeStruct %uint
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %11 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %12 = OpTypeFunction %void
- %1 = OpFunction %void None %12
- %13 = OpLabel
- %14 = OpAccessChain %_ptr_Uniform_uint %11 %uint_0
- %15 = OpLoad %uint %14
- %al = OpAtomicLoad %uint %14 %uint_4 %mem_semantics
- OpSelectionMerge %16 None
- OpBranchConditional %true %17 %20
- %20 = OpLabel
- OpBranch %16
- %17 = OpLabel
- %18 = OpCopyObject %uint %15
- OpBranch %16
- %16 = OpLabel
- OpReturn
- OpFunctionEnd
- )";
- auto result = SinglePassRunAndDisassemble<CodeSinkingPass>(
- text, /* skip_nop = */ true, /* do_validation = */ true);
- EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
- }
- TEST_F(CodeSinkTest, MoveWithAtomicWithoutSync) {
- const std::string text = R"(
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main"
- OpDecorate %_arr_uint_uint_4 BufferBlock
- OpMemberDecorate %_arr_uint_uint_4 0 Offset 0
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %uint = OpTypeInt 32 0
- %uint_0 = OpConstant %uint 0
- %uint_4 = OpConstant %uint 4
- %_arr_uint_uint_4 = OpTypeStruct %uint
- %_ptr_Uniform_uint = OpTypePointer Uniform %uint
- %_ptr_Uniform__arr_uint_uint_4 = OpTypePointer Uniform %_arr_uint_uint_4
- %11 = OpVariable %_ptr_Uniform__arr_uint_uint_4 Uniform
- %12 = OpTypeFunction %void
- %1 = OpFunction %void None %12
- %13 = OpLabel
- %14 = OpAccessChain %_ptr_Uniform_uint %11 %uint_0
- %15 = OpLoad %uint %14
- %al = OpAtomicLoad %uint %14 %uint_4 %uint_0
- OpSelectionMerge %16 None
- OpBranchConditional %true %17 %20
- %20 = OpLabel
- OpBranch %16
- %17 = OpLabel
- %18 = OpCopyObject %uint %15
- OpBranch %16
- %16 = OpLabel
- OpReturn
- OpFunctionEnd
- )";
- auto result = SinglePassRunAndDisassemble<CodeSinkingPass>(
- text, /* skip_nop = */ true, /* do_validation = */ true);
- EXPECT_EQ(Pass::Status::SuccessWithChange, std::get<1>(result));
- }
- TEST_F(CodeSinkTest, DecorationOnLoad) {
- const std::string text = R"(
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %1 "main" %2
- OpDecorate %3 RelaxedPrecision
- %void = OpTypeVoid
- %5 = OpTypeFunction %void
- %float = OpTypeFloat 32
- %_ptr_Input_float = OpTypePointer Input %float
- %2 = OpVariable %_ptr_Input_float Input
- %1 = OpFunction %void None %5
- %8 = OpLabel
- %3 = OpLoad %float %2
- OpReturn
- OpFunctionEnd
- )";
- // We just want to make sure the code does not crash.
- auto result = SinglePassRunAndDisassemble<CodeSinkingPass>(
- text, /* skip_nop = */ true, /* do_validation = */ true);
- EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
- }
- } // namespace
- } // namespace opt
- } // namespace spvtools
|