[llvm] [SPIRV] Emit NonSemantic DebugValue (PR #224158)

Juan Manuel Martinez CaamaƱo via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 06:26:36 PDT 2026


================
@@ -1946,6 +2410,21 @@ void SPIRVNonSemanticDebugHandler::emitNonSemanticGlobalDebugInfo(
     if (const DILocation *IA = DL->getInlinedAt())
       getOrEmitDebugInlinedAt(IA, VoidTypeReg, I32TypeReg, ExtInstSetReg, MAI);
 
+  // Both maps are populated by now, so repeating the lookups that
+  // emitDebugBinding() performs emits a type and a constant only for an
+  // assignment that will reach a DebugValue.
+  for (const SPIRV::ConstantAssignment &CA : ConstantAssignments) {
+    if (!DebugLocalVariableRegs.contains(CA.Var) ||
+        !DebugExpressionRegs.contains(CA.Expr))
+      continue;
+    auto [It, Inserted] =
+        ConstantValueRegs.try_emplace({CA.Type, CA.Bits}, MCRegister());
+    if (Inserted)
+      It->second = findOrEmitScalarConstant(CA.Type, CA.Bits, MAI);
----------------
jmmartinez wrote:

If I understand, we need this because a type/constant may appear in the debug-info, but not in the intermediate representation.

So we need to sort of "reinvent" the emission of float/integer constants? 

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


More information about the llvm-commits mailing list