diff --git a/llpc/test/shaderdb/debug_info/FunctionCall.pipe b/llpc/test/shaderdb/debug_info/FunctionCall.pipe index 184307d7a0..f551e320eb 100644 --- a/llpc/test/shaderdb/debug_info/FunctionCall.pipe +++ b/llpc/test/shaderdb/debug_info/FunctionCall.pipe @@ -1,8 +1,12 @@ ; RUN: amdllpc -trim-debug-info=false -filetype=asm -o - -gfxip 11.0 %s | FileCheck -check-prefixes=NOTRIM %s +; RUN: amdllpc -trim-debug-info=true -filetype=asm -o - -gfxip 11.0 %s | FileCheck -check-prefixes=TRIM %s ; Just a simple sanity check that the compiler ran through and produced *some* debug info ; NOTRIM: .loc 1 11 0 prologue_end +; TRIM-NOT: .loc +; TRIM: s_endpgm + [CsSpirv] ; Compiled with glslangValidator --target-env vulkan1.3 -gVS ; SPIR-V diff --git a/llpc/util/llpcShaderModuleHelper.cpp b/llpc/util/llpcShaderModuleHelper.cpp index 330ad95500..56bd1f4232 100644 --- a/llpc/util/llpcShaderModuleHelper.cpp +++ b/llpc/util/llpcShaderModuleHelper.cpp @@ -254,10 +254,13 @@ unsigned ShaderModuleHelper::trimSpirvDebugInfo(const BinaryData *spvBin, llvm:: codeBuffer = codeBuffer.drop_front(sizeof(Vkgc::SpirvHeader) / wordSize); } + unsigned nonSemanticShaderDebug = ~0; + // Copy SPIR-V instructions while (codePos < end) { unsigned opCode = (codePos[0] & OpCodeMask); unsigned wordCount = (codePos[0] >> WordCountShift); + bool skip = false; switch (opCode) { case OpSource: case OpSourceContinued: @@ -266,12 +269,29 @@ unsigned ShaderModuleHelper::trimSpirvDebugInfo(const BinaryData *spvBin, llvm:: case OpLine: case OpNop: case OpNoLine: - case OpModuleProcessed: { - // Skip debug instructions + case OpModuleProcessed: + skip = true; + break; + case OpExtInstImport: { + unsigned id = codePos[1]; + const char *name = reinterpret_cast(&codePos[2]); + if (!strcmp(name, "NonSemantic.Shader.DebugInfo.100")) { + nonSemanticShaderDebug = id; + skip = true; + } break; } - default: { - // Copy other instructions + case OpExtInst: { + unsigned set = codePos[3]; + if (set == nonSemanticShaderDebug) + skip = true; + break; + } + default: + break; + } + + if (!skip) { if (writeCode) { assert(codePos + wordCount <= end); assert(wordCount <= codeBuffer.size()); @@ -279,8 +299,6 @@ unsigned ShaderModuleHelper::trimSpirvDebugInfo(const BinaryData *spvBin, llvm:: codeBuffer = codeBuffer.drop_front(wordCount); } totalSizeInWords += wordCount; - break; - } } codePos += wordCount;