[llvm] [SPIRV] Emit NonSemantic DebugGlobalVariable (PR #207230)

Manuel Carrasco via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 03:29:07 PDT 2026


================
@@ -251,6 +255,27 @@ void SPIRVNonSemanticDebugHandler::beginModule(Module *M) {
     if (!SP->isDefinition())
       SubprogramDeclarations.push_back(SP);
   }
+
+  // Map DIGlobalVariable -> llvm::GlobalVariable for globals that attach !dbg.
+  // The link lives on the IR global (via DIGlobalVariableExpression); DIGV
+  // metadata has no back-reference to its @g.
+  for (const GlobalVariable &G : M->globals()) {
+    SmallVector<DIGlobalVariableExpression *, 4> GVEs;
+    G.getDebugInfo(GVEs);
+    for (DIGlobalVariableExpression *GVE : GVEs)
+      DIGVToLLVMGV.try_emplace(GVE->getVariable(), &G);
+  }
----------------
mgcarrasco wrote:

Simplified processing, we now build the map based on the DIGlobalVariableExpressions returned by the DIFinder. 

https://github.com/llvm/llvm-project/pull/207230


More information about the llvm-commits mailing list