[llvm] [SPIRV] Emit NonSemantic DebugDeclare, DebugExpression and DebugOperation (PR #222011)

Manuel Carrasco via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 06:13:37 PDT 2026


================
@@ -1729,9 +1890,22 @@ void SPIRVNonSemanticDebugHandler::emitNonSemanticGlobalDebugInfo(
   }
 
   // Emit DebugLocalVariable after DebugFunction and their lexical blocks so the
-  // Parent operand can resolve.
+  // Parent operand can resolve. Record the ids for DebugDeclare.
   for (const DILocalVariable *LV : LocalVariables)
-    emitDebugLocalVariable(LV, VoidTypeReg, I32TypeReg, ExtInstSetReg, MAI);
+    if (auto LVReg = emitDebugLocalVariable(LV, VoidTypeReg, I32TypeReg,
+                                            ExtInstSetReg, MAI))
+      DebugLocalVariableRegs[LV] = *LVReg;
+
+  // Opcodes like DebugDeclare are part of the function body, but
+  // DebugExpression cannot. For such opcodes, we collect the expressions
+  // directly from the MIR to avoid inconsistencies with those in the LLVM IR
+  // module.
+  SetVector<const DIExpression *> Expressions;
+  collectDebugExpressions(Expressions);
+  for (const DIExpression *Expr : Expressions)
+    if (auto ExprReg = emitDebugExpression(Expr, VoidTypeReg, I32TypeReg,
+                                           ExtInstSetReg, MAI))
+      DebugExpressionRegs[Expr] = *ExprReg;
----------------
mgcarrasco wrote:

Now we have caching for DebugExpression to handle the GV vs MIR case. Also, we have caching for DebugOperation.

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


More information about the llvm-commits mailing list