@@ -2598,6 +2598,70 @@ TEST_F(MergeReturnPassTest, OverflowTest1) {
2598
2598
EXPECT_EQ (Pass::Status::Failure, std::get<1 >(result));
2599
2599
}
2600
2600
2601
+ TEST_F (MergeReturnPassTest, DebugFunctionDefinitionStillInEntryBlock) {
2602
+ // Make sure that the DebugFunctionDefinition instruction is still in the
2603
+ // entry block
2604
+ const std::string text =
2605
+ R"(
2606
+ ; CHECK: OpFunction
2607
+ ; CHECK: OpLabel
2608
+ ; CHECK: DebugFunctionDefinition
2609
+ ; CHECK: OpSelectionMerge
2610
+ ; CHECK: OpCompositeExtract
2611
+ ; CHECK: OpUGreaterThan
2612
+ OpCapability Shader
2613
+ OpExtension "SPV_KHR_non_semantic_info"
2614
+ %2 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
2615
+ OpMemoryModel Logical GLSL450
2616
+ OpEntryPoint GLCompute %main "main" %entryPointParam_main %gl_GlobalInvocationID
2617
+ %1 = OpString "test"
2618
+ OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
2619
+ OpDecorate %entryPointParam_main Location 0
2620
+ %void = OpTypeVoid
2621
+ %4 = OpExtInst %void %2 DebugSource %1
2622
+ %uint = OpTypeInt 32 0
2623
+ %uint_100 = OpConstant %uint 100
2624
+ %uint_5 = OpConstant %uint 5
2625
+ %uint_11 = OpConstant %uint 11
2626
+ %10 = OpExtInst %void %2 DebugCompilationUnit %uint_100 %uint_5 %4 %uint_11
2627
+ %12 = OpTypeFunction %void
2628
+ %uint_0 = OpConstant %uint 0
2629
+ %14 = OpExtInst %void %2 DebugTypeFunction %uint_0 %void
2630
+ %uint_2 = OpConstant %uint 2
2631
+ %16 = OpExtInst %void %2 DebugFunction %1 %14 %4 %uint_2 %uint_5 %10 %1 %uint_0 %uint_2
2632
+ %v3uint = OpTypeVector %uint 3
2633
+ %_ptr_Input_v3uint = OpTypePointer Input %v3uint
2634
+ %bool = OpTypeBool
2635
+ %uint_3 = OpConstant %uint 3
2636
+ %int = OpTypeInt 32 1
2637
+ %_ptr_Output_int = OpTypePointer Output %int
2638
+ %int_1 = OpConstant %int 1
2639
+ %int_0 = OpConstant %int 0
2640
+ %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input ; BuiltIn GlobalInvocationId
2641
+ %entryPointParam_main = OpVariable %_ptr_Output_int Output ; Location 0
2642
+
2643
+ ; Function main
2644
+ %main = OpFunction %void None %12
2645
+ %13 = OpLabel
2646
+ %20 = OpExtInst %void %2 DebugScope %16
2647
+ %29 = OpLoad %v3uint %gl_GlobalInvocationID
2648
+ %37 = OpCompositeExtract %uint %29 0
2649
+ %39 = OpUGreaterThan %bool %37 %uint_3
2650
+ %19 = OpExtInst %void %2 DebugFunctionDefinition %16 %main
2651
+ OpSelectionMerge %21 None
2652
+ OpBranchConditional %39 %23 %21
2653
+ %21 = OpLabel
2654
+ OpStore %entryPointParam_main %int_1
2655
+ OpReturn
2656
+ %23 = OpLabel
2657
+ OpStore %entryPointParam_main %int_0
2658
+ OpReturn
2659
+ OpFunctionEnd
2660
+ )" ;
2661
+
2662
+ SinglePassRunAndMatch<MergeReturnPass>(text, true );
2663
+ }
2664
+
2601
2665
} // namespace
2602
2666
} // namespace opt
2603
2667
} // namespace spvtools
0 commit comments