[clang] [llvm] Disentangle DISubprogram ODR type method uniquing from metadata uniquing (PR #217042)

Vladislav Dzhidzhoev via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 22 19:04:40 PDT 2026


================
@@ -529,6 +530,9 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
                  "use of undefined value '@" +
                      Twine(ForwardRefValIDs.begin()->first) + "'");
 
+  if (Context.isODRUniquingDebugTypes())
+    Context.getDebugTypeODRUniquer()->finalizeUnresolvedSubprogramDecls();
+
   // Resolve metadata cycles.
----------------
dzhidzhoev wrote:

Not sure if the similar issue pops up when parsing .bc files, but a cycle may trigger assertion here, since not every node is marked as resolved yet:
```
$ cat cycle.ll
!namednode = !{!0}
!0 = !DISubprogram(name: "f", linkageName: "f", scope: !1, type: !2, spFlags: 0)
!1 = !DICompositeType(tag: DW_TAG_structure_type, name: "C", elements: !3)
!2 = !DISubroutineType(types: !4)
!3 = !{!0}
!4 = !{null}

$ llvm-as cycle.ll -o /dev/null
llvm-as: /home/vlad/llvm/llvm-project/llvm/lib/IR/DebugInfoODRUniquer.cpp:75: void llvm::DebugInfoODRUniquer::finalizeUnresolvedSubprogramDecls(): Assertion `NewSP->isResolved() && "expected SP to be resolved"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
```

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


More information about the cfe-commits mailing list