[llvm] [SPIRV] LLVM IR DIScope nodes are now emitted after their dependencies. (PR #227361)
Juan Manuel Martinez CaamaƱo via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 05:57:15 PDT 2026
================
@@ -833,13 +835,160 @@ MCRegister SPIRVNonSemanticDebugHandler::findOrEmitOpTypeInt32(
return Reg;
}
-std::optional<MCRegister> SPIRVNonSemanticDebugHandler::emitDebugTypePointer(
+// Each node emits its dependencies first. E.g. for `void f() { struct L; }`,
+// node L emits f, then L. For `struct S { S *p; }`, S* is a back edge, so S
+// is emitted without member p.
+SPIRVNonSemanticDebugHandler::EmitResult
+SPIRVNonSemanticDebugHandler::getOrCreateDebugScope(const DIScope *S) {
+ if (!S || FailedScopes.contains(S))
+ return EmitResult::unsupported();
+ if (auto Reg = lookupOptReg(DebugScopeRegs, S))
+ return EmitResult::emitted(*Reg);
+
+ // Mark the node as in progress while its dependencies are resolved/emitted.
+ // This also prevents cycles from happening.
+ if (!ScopesInProgress.insert(S).second)
+ return EmitResult::inProgress();
+ EmitResult R = emitDebugScope(S);
+ ScopesInProgress.erase(S);
+ assert((!R || !GlobalNSDIEnabled) &&
+ "debug type or scope created after module-scope NSDI emission");
+ if (R)
+ DebugScopeRegs[S] = R.Reg;
+ else if (R.Status == EmitStatus::Unsupported)
+ FailedScopes.insert(S);
----------------
jmmartinez wrote:
Well spotted. It's ok for me then.
https://github.com/llvm/llvm-project/pull/227361
More information about the llvm-commits
mailing list