From d166fe8333c7dfc61c32fda5017461858eb4c3fa Mon Sep 17 00:00:00 2001 From: Lujin Wang <143145775+lujinwangnv@users.noreply.github.com> Date: Thu, 26 Jun 2025 09:29:32 -0700 Subject: Correct the scope for DebugLocalVariable (#7516) * Correct the scope for DebugLocalVariable All of the DebugLocalVariable instructions have their scope set to DebugCompilationUnit. The scope should instead be set to a DebugFunction, or a DebugLexicalBlock which is recursively inside a DebugFunction. Register the debug info for the function instructions, which helps findDebugScope() to find the right DebugFunction scope for DebugLocalVariable. * Add a test for DebugLocalVariable To check the scope, which should be a DebugFunction. --- tests/spirv/debug-local-variable-scope.slang | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/spirv/debug-local-variable-scope.slang (limited to 'tests/spirv') diff --git a/tests/spirv/debug-local-variable-scope.slang b/tests/spirv/debug-local-variable-scope.slang new file mode 100644 index 000000000..22f6aef2e --- /dev/null +++ b/tests/spirv/debug-local-variable-scope.slang @@ -0,0 +1,21 @@ +//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry main -stage fragment -g2 -emit-spirv-directly + +Texture2D testTex : register(t0); +SamplerState testSampler : register(s0); + +struct PSIn +{ + float4 pos : SV_Position; +}; + +float4 main(PSIn input) : SV_TARGET +{ + uint4 testPos = input.pos; + float bias = -1.0; + float2 tc = testPos.xy / 32.0; + float4 colVal = testTex.SampleBias(testSampler, tc, bias); + return float4(colVal.xyz, 1.0); +} + +// CHECK: %[[FUNC_ID:[0-9]+]] = OpExtInst %void {{.*}} DebugFunction %{{[0-9]+}} +// CHECK: DebugLocalVariable %{{[0-9]+}} %{{[0-9]+}} %{{[0-9]+}} %{{.*}} %{{.*}} %[[FUNC_ID]] -- cgit v1.2.3