From c19e2e92ae8e713225262a17f39a438cd511d416 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Thu, 28 Aug 2025 10:45:07 -0700 Subject: Remove the embedded source to avoid self-matching in slang-test (#8305) When `SIMPLE` type test is used with `-g[1-3]` option, the filecheck pattern will most likely to match to the string itself on the embedded source code rather than match to the emitted spirv-asm code. This commit avoids the problem by removing the embedded source code. This commit also provides an option to keep the embedded source code, `-preserve-embedded-source`. The source code removal is happening in two steps: 1. iterate all output lines and find SPIRV-ASM in the following pattern: `%N = OpExtInst %void %M DebugSource %fileId %sourceId`. And then, store the "%sourceId" value to identify which SPIRV instructions are for the embedded source code. 2. iterate all output lines again to find the `%sourceId = OpString "...."` and replace the whole string with the following string, ``` %1 = OpString "// slang-test removed the embedded source // Use `-preserve-embedded-source` to keep it explicitly " ``` This change revealed problems in the existing tests: - tests/bugs/spirv-debug-info.slang : The expected text was missing and it had to be added. The file also had Carrage-Return character on all lines and the pre-commit git hook removed them. - tests/spirv/debug-info.slang : the expected keyword DebugValue had to change to DebugDeclare, because that's what we get with ToT. - tests/spirv/debug-value-dynamic-index.slang : This test is currently failing, and it will pass once DebugLocalVariable instruction missing for parameter of the entry point function #7693 is resolved. --------- Co-authored-by: slangbot --- tests/bugs/spirv-debug-info.slang | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tests/bugs') diff --git a/tests/bugs/spirv-debug-info.slang b/tests/bugs/spirv-debug-info.slang index 500299057..fe1c4fb05 100644 --- a/tests/bugs/spirv-debug-info.slang +++ b/tests/bugs/spirv-debug-info.slang @@ -1,5 +1,5 @@ -//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry MainPs -stage fragment -profile glsl_450 -g3 -line-directive-mode none -//TEST:SIMPLE(filecheck=CHECK-SPIRV):-target spirv -entry MainPs -stage fragment -profile glsl_450 -g3 -emit-spirv-directly +//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry MainPs -stage fragment -profile glsl_450 -g3 -line-directive-mode none -preserve-embedded-source +//TEST:SIMPLE(filecheck=CHECK-SPIRV):-target spirv -entry MainPs -stage fragment -profile glsl_450 -g3 -emit-spirv-directly -preserve-embedded-source // make sure that the generated spirv has glsl source in it. // CHECK: #version 450 @@ -10,14 +10,14 @@ // CHECK-SPIRV: {{.*}} OpFunction // CHECK-SPIRV: {{.*}} = OpExtInst %void {{.*}} DebugLine -struct PS_OUTPUT -{ - float4 vColor : SV_Target0 ; -} ; +struct PS_OUTPUT +{ + float4 vColor : SV_Target0 ; +} ; -PS_OUTPUT MainPs ( ) -{ - PS_OUTPUT o ; - o . vColor = float4 ( 0 , 0 , 0 , 0 ) ; - return o ; -} \ No newline at end of file +PS_OUTPUT MainPs ( ) +{ + PS_OUTPUT o ; + o . vColor = float4 ( 0 , 0 , 0 , 0 ) ; + return o ; +} -- cgit v1.2.3