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

Diego Novillo via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 07:02:09 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);
----------------
dnovillo wrote:

Yes, and the handler already did this before the patch: every line, column and flags number in the debug info has to exist as a constant in the module, so it already searched for one and emitted it when missing. This change extends the same search to booleans and the remaining scalar types.

The normal constant-creation path is not available this late, since it builds machine instructions and the module's type and constant section is already closed by the time the handler runs.

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


More information about the llvm-commits mailing list