[llvm] Add support for DebugLexicalBlock. (PR #217965)
Juan Manuel Martinez CaamaƱo via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 03:07:04 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(
+ const DIScope *Scope) const {
+ if (isa_and_nonnull<DILexicalBlock>(Scope) ||
+ isa_and_nonnull<DINamespace>(Scope))
+ return lookupOptReg(DebugLexicalBlockRegs, Scope);
+ if (const auto *SP = dyn_cast_or_null<DISubprogram>(Scope))
+ return lookupOptReg(DebugFunctionRegs, SP);
+ if (CompileUnits.empty())
+ return std::nullopt;
+ return lookupOptReg(CUToCompilationUnitDbgReg, CompileUnits[0].TheCU);
+}
+
+std::optional<MCRegister> SPIRVNonSemanticDebugHandler::emitDebugLexicalBlock(
+ const DIScope *S, MCRegister VoidTypeReg, MCRegister I32TypeReg,
+ MCRegister ExtInstSetReg, SPIRV::ModuleAnalysisInfo &MAI) {
+ assert((isa<DILexicalBlock>(S) || isa<DINamespace>(S)) &&
----------------
jmmartinez wrote:
You could use the `isa<DILexicalBlock, DINamespace>` as you did above?
https://github.com/llvm/llvm-project/pull/217965
More information about the llvm-commits
mailing list