[llvm] Add support for DebugLexicalBlock. (PR #217965)

Juan Manuel Martinez CaamaƱo via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 01:55:33 PDT 2026


================
@@ -657,14 +682,65 @@ std::optional<MCRegister> SPIRVNonSemanticDebugHandler::resolveTypeScopeParent(
   if (const auto *Ty = dyn_cast_or_null<DIType>(Scope))
     return lookupOptReg(DebugTypeRegs, Ty);
 
-  // For a file, compile-unit, namespace, or absent scope, the parent is the
-  // first module DebugCompilationUnit.
+  // Find the DINamespace that was emitted as a lexical block.
+  if (isa_and_nonnull<DINamespace>(Scope))
+    return lookupOptReg(DebugLexicalBlockRegs, Scope);
+
+  // For a file, compile-unit, or absent scope, the parent is the first module
+  // DebugCompilationUnit.
   if (CompileUnits.empty())
     return std::nullopt;
 
   return lookupOptReg(CUToCompilationUnitDbgReg, CompileUnits[0].TheCU);
 }
 
+std::optional<MCRegister>
+SPIRVNonSemanticDebugHandler::resolveLexicalBlockParent(
----------------
jmmartinez wrote:

I've tested this and it works (at least in the current commit).

The only odd thing is that we have to take a `FallbackCU` due to `DISubprogram` `SP->getUnit()` code path, which doesn't apply to the others.

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


More information about the llvm-commits mailing list