@@ -4471,6 +4471,86 @@ TEST_F(InlineTest, DecorateReturnVariableWithAliasedPointer) {
44714471 SinglePassRunAndMatch<InlineExhaustivePass>(text, true );
44724472}
44734473
4474+ TEST_F (InlineTest, DebugDeclareWithAccessChain) {
4475+ const std::string text = R"(
4476+ ; CHECK: [[EmptyStruct:%[\w]+]] = OpTypeStruct %float
4477+ ; CHECK-DAG: [[Struct:%[\w]+]] = OpTypeStruct [[EmptyStruct]]
4478+ ; CHECK-DAG: [[PtrType:%[\w]+]] = OpTypePointer Function [[Struct]]
4479+ ; CHECK-DAG: [[EmptyPtrType:%[\w]+]] = OpTypePointer Function [[EmptyStruct]]
4480+ OpCapability Shader
4481+ OpExtension "SPV_KHR_non_semantic_info"
4482+ OpExtension "SPV_KHR_relaxed_extended_instruction"
4483+ %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
4484+ OpMemoryModel Logical GLSL450
4485+ OpEntryPoint GLCompute %2 "computeMain"
4486+ OpExecutionMode %2 LocalSize 1 1 1
4487+ %3 = OpString "s.hlsl"
4488+ %4 = OpString "float"
4489+ %5 = OpString "source"
4490+ %6 = OpString "a"
4491+ %7 = OpString "SomeStruct"
4492+ %8 = OpString "SomeStruct.getA"
4493+ %9 = OpString ""
4494+ %10 = OpString "this"
4495+ %int = OpTypeInt 32 1
4496+ %int_0 = OpConstant %int 0
4497+ %uint = OpTypeInt 32 0
4498+ %uint_0 = OpConstant %uint 0
4499+ %uint_32 = OpConstant %uint 32
4500+ %float = OpTypeFloat 32
4501+ %void = OpTypeVoid
4502+ %uint_3 = OpConstant %uint 3
4503+ %uint_1 = OpConstant %uint 1
4504+ %uint_4 = OpConstant %uint 4
4505+ %uint_5 = OpConstant %uint 5
4506+ %uint_11 = OpConstant %uint 11
4507+ %uint_8 = OpConstant %uint 8
4508+ %uint_288 = OpConstant %uint 288
4509+ %25 = OpTypeFunction %void
4510+ %_struct_26 = OpTypeStruct %float
4511+ %_struct_27 = OpTypeStruct %_struct_26
4512+ %_ptr_Function__struct_27 = OpTypePointer Function %_struct_27
4513+ %_ptr_Function__struct_26 = OpTypePointer Function %_struct_26
4514+ %_ptr_Function_float = OpTypePointer Function %float
4515+ %30 = OpTypeFunction %float %_ptr_Function__struct_26 %_ptr_Function_float
4516+ %31 = OpUndef %float
4517+ %32 = OpExtInst %void %1 DebugTypeBasic %4 %uint_32 %uint_3 %uint_0
4518+ %33 = OpExtInst %void %1 DebugSource %3 %5
4519+ %34 = OpExtInst %void %1 DebugCompilationUnit %uint_1 %uint_4 %33 %uint_5
4520+ %35 = OpExtInst %void %1 DebugTypeMember %6 %32 %33 %uint_3 %uint_11 %uint_0 %uint_32 %uint_3
4521+ %36 = OpExtInstWithForwardRefsKHR %void %1 DebugTypeComposite %7 %uint_1 %33 %uint_1 %uint_8 %34 %7 %uint_32 %uint_3 %35 %37
4522+ %38 = OpExtInst %void %1 DebugTypeFunction %uint_3 %32 %36
4523+ %37 = OpExtInst %void %1 DebugFunction %8 %38 %33 %uint_4 %uint_5 %36 %9 %uint_3 %uint_4
4524+ %39 = OpExtInst %void %1 DebugLocalVariable %10 %36 %33 %uint_4 %uint_5 %37 %uint_288 %uint_1
4525+ %52 = OpExtInst %void %1 DebugLocalVariable %10 %32 %33 %uint_4 %uint_5 %37 %uint_288 %uint_1
4526+ %40 = OpExtInst %void %1 DebugExpression
4527+ ; CHECK: OpFunction %void None
4528+ ; CHECK: [[Var:%[\w]+]] = OpVariable [[PtrType]] Function
4529+ ; CHECK: OpExtInst %void {{%[\w+]+}} DebugDeclare {{%[\w+]+}} [[Var]] {{%[\w+]+}} %int_0
4530+ ; CHECK: OpExtInst %void {{%[\w+]+}} DebugDeclare {{%[\w+]+}} [[Var]] {{%[\w+]+}} %int_0 %int_0
4531+ %2 = OpFunction %void None %25
4532+ %41 = OpLabel
4533+ %42 = OpVariable %_ptr_Function__struct_27 Function
4534+ %43 = OpAccessChain %_ptr_Function__struct_26 %42 %int_0
4535+ %49 = OpAccessChain %_ptr_Function_float %43 %int_0
4536+ %44 = OpFunctionCall %float %45 %43 %49
4537+ OpReturn
4538+ OpFunctionEnd
4539+ ; CHECK: OpFunction %float None
4540+ %45 = OpFunction %float None %30
4541+ %46 = OpFunctionParameter %_ptr_Function__struct_26
4542+ %50 = OpFunctionParameter %_ptr_Function_float
4543+ %47 = OpLabel
4544+ %48 = OpExtInst %void %1 DebugDeclare %39 %46 %40
4545+ %51 = OpExtInst %void %1 DebugDeclare %52 %50 %40
4546+ OpReturnValue %31
4547+ OpFunctionEnd
4548+ )" ;
4549+
4550+ SetTargetEnv (SPV_ENV_VULKAN_1_2);
4551+ SinglePassRunAndMatch<InlineExhaustivePass>(text, true );
4552+ }
4553+
44744554// TODO(greg-lunarg): Add tests to verify handling of these cases:
44754555//
44764556// Empty modules
0 commit comments