@@ -8799,6 +8799,69 @@ TEST_F(AggressiveDCETest, UndefIsOutsideFunction) {
87998799 OpReturn
88008800 OpFunctionEnd
88018801
8802+ )" ;
8803+
8804+ SinglePassRunAndMatch<AggressiveDCEPass>(spirv, true );
8805+ }
8806+ TEST_F (AggressiveDCETest, ConvertDebugDeclareToDebugValue) {
8807+ const std::string spirv =
8808+ R"( OpCapability Shader
8809+ OpExtension "SPV_KHR_non_semantic_info"
8810+ %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
8811+ OpMemoryModel Logical GLSL450
8812+ OpEntryPoint Fragment %main "main" %input %output
8813+ OpExecutionMode %main OriginUpperLeft
8814+ %5 = OpString "test.hlsl"
8815+ OpSource HLSL 600
8816+ OpName %main "main"
8817+ OpDecorate %input Location 0
8818+ OpDecorate %output Location 0
8819+ %void = OpTypeVoid
8820+ %float = OpTypeFloat 32
8821+ %v4float = OpTypeVector %float 4
8822+ %uint = OpTypeInt 32 0
8823+ %uint_1 = OpConstant %uint 1
8824+ %uint_2 = OpConstant %uint 2
8825+ %uint_3 = OpConstant %uint 3
8826+ %uint_32 = OpConstant %uint 32
8827+ %uint_0 = OpConstant %uint 0
8828+ %float_1 = OpConstant %float 1
8829+ %_ptr_Input_v4float = OpTypePointer Input %v4float
8830+ %_ptr_Output_v4float = OpTypePointer Output %v4float
8831+ %_ptr_Function_v4float = OpTypePointer Function %v4float
8832+ %input = OpVariable %_ptr_Input_v4float Input
8833+ %output = OpVariable %_ptr_Output_v4float Output
8834+ %29 = OpTypeFunction %void
8835+ ; CHECK: [[expr:%\w+]] = OpExtInst %void {{%\w+}} DebugExpression
8836+ ; CHECK: [[source:%\w+]] = OpExtInst %void {{%\w+}} DebugSource %5
8837+ %30 = OpExtInst %void %1 DebugSource %5
8838+ %31 = OpExtInst %void %1 DebugCompilationUnit %uint_1 %uint_3 %30 %uint_32
8839+ ; CHECK: [[basic:%\w+]] = OpExtInst %void {{%\w+}} DebugTypeBasic
8840+ %32 = OpExtInst %void %1 DebugTypeBasic %5 %uint_32 %uint_3 %uint_0
8841+ ; CHECK: [[vec_type:%\w+]] = OpExtInst %void {{%\w+}} DebugTypeVector [[basic]] %uint_3
8842+ %33 = OpExtInst %void %1 DebugTypeVector %32 %uint_3
8843+ %34 = OpExtInst %void %1 DebugTypeFunction %uint_0 %void
8844+ %35 = OpExtInst %void %1 DebugFunction %5 %34 %30 %uint_1 %uint_0 %31 %5 %uint_0 %uint_1
8845+ %36 = OpExtInst %void %1 DebugLocalVariable %5 %33 %30 %uint_1 %uint_0 %35 %uint_0
8846+ ; CHECK: [[local:%\w+]] = OpExtInst %void {{%\w+}} DebugLocalVariable %5 [[vec_type]] [[source]] %uint_2
8847+ %37 = OpExtInst %void %1 DebugLocalVariable %5 %33 %30 %uint_2 %uint_0 %35 %uint_0
8848+ %38 = OpExtInst %void %1 DebugExpression
8849+ %main = OpFunction %void None %29
8850+ %39 = OpLabel
8851+ %dead_var = OpVariable %_ptr_Function_v4float Function
8852+ %live_var = OpVariable %_ptr_Function_v4float Function
8853+ ; CHECK: [[live:%\w+]] = OpLoad
8854+ %live_input = OpLoad %v4float %input
8855+ %dead_value = OpCompositeConstruct %v4float %float_1 %float_1 %float_1 %float_1
8856+ OpStore %dead_var %dead_value
8857+ ; CHECK-NOT: DebugDeclare
8858+ %40 = OpExtInst %void %1 DebugDeclare %36 %dead_var %38
8859+ OpStore %live_var %live_input
8860+ ; CHECK: DebugValue [[local]] [[live]] [[expr]]
8861+ %41 = OpExtInst %void %1 DebugDeclare %37 %live_var %38
8862+ OpStore %output %live_input
8863+ OpReturn
8864+ OpFunctionEnd
88028865)" ;
88038866
88048867 SinglePassRunAndMatch<AggressiveDCEPass>(spirv, true );
0 commit comments