[llvm-branch-commits] [llvm] [SPIRV][Debug Info] Fix debug info placement logic for DebugFunctionDefinition (PR #183121)
Manuel Carrasco via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Feb 25 09:33:40 PST 2026
https://github.com/mgcarrasco updated https://github.com/llvm/llvm-project/pull/183121
>From 041092cb1cb7b08c23839a11894a5c98ccc46380 Mon Sep 17 00:00:00 2001
From: Manuel Carrasco <Manuel.Carrasco at amd.com>
Date: Tue, 24 Feb 2026 10:57:31 -0600
Subject: [PATCH] [SPIRV] Refactor NonSemantic debug info placement logic.
Refactor the logic for determining which NonSemantic.Shader.DebugInfo.100
instructions should be placed in the global section from a whitelist
to a blacklist approach.
---
llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp | 21 ++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
index 7a9dfc63a3f1b..94293114733ae 100644
--- a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
@@ -657,13 +657,20 @@ void SPIRVModuleAnalysis::processOtherInstrs(const Module &M) {
NonSemantic_Shader_DebugInfo_100) {
MachineOperand Ins = MI.getOperand(3);
namespace NS = SPIRV::NonSemanticExtInst;
- static constexpr int64_t GlobalNonSemanticDITy[] = {
- NS::DebugSource, NS::DebugCompilationUnit, NS::DebugInfoNone,
- NS::DebugTypeBasic, NS::DebugTypePointer};
- bool IsGlobalDI = false;
- for (unsigned Idx = 0; Idx < std::size(GlobalNonSemanticDITy); ++Idx)
- IsGlobalDI |= Ins.getImm() == GlobalNonSemanticDITy[Idx];
- if (IsGlobalDI)
+ // Debug info extension instructions other than DebugScope,
+ // DebugNoScope, DebugDeclare, DebugValue, DebugFunctionDefinition
+ // must appear between section 9 (types, constants, global variables)
+ // and section 10 (function declarations).
+ // DebugFunctionDefinition must appear in the entry basic block of an
+ // OpFunction, so it should not be moved to the global section.
+ static constexpr int64_t ExcludedFromGlobalDI[] = {
+ NS::DebugScope, NS::DebugNoScope, NS::DebugDeclare,
+ NS::DebugValue, NS::DebugFunctionDefinition};
+ bool IsExcluded = false;
+ for (unsigned Idx = 0; Idx < std::size(ExcludedFromGlobalDI); ++Idx)
+ IsExcluded |= Ins.getImm() == ExcludedFromGlobalDI[Idx];
+ // All other NonSemantic debug info instructions go to global section
+ if (!IsExcluded)
collectOtherInstr(MI, MAI, SPIRV::MB_NonSemanticGlobalDI, IS);
} else if (OpCode == SPIRV::OpName || OpCode == SPIRV::OpMemberName) {
collectOtherInstr(MI, MAI, SPIRV::MB_DebugNames, IS);
More information about the llvm-branch-commits
mailing list