[clang] [llvm] [llvm][DebugInfo] Avoid attaching retained nodes to unrelated subprograms in DIBuilder (PR #180294)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 9 05:04:21 PST 2026


================
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -debug-info-kind=limited -dwarf-version=5 -O0 -disable-llvm-passes %s -o - \
+// RUN:        | FileCheck %s
+
+// When compiling this with limited debug info, a replaceable forward declaration DICompositeType
+// for "n" is created in the scope of base object constructor (C2) of class l, and it's not immediately
+// replaced with a distinct node (the type is not "completed").
+// Later, it gets replaced with distinct definition DICompositeType, which is created in the scope of
+// complete object constructor (C1).
+//
+// In contrast to that, in standalone debug info mode, the complete definition DICompositeType
+// for "n" is created sooner, right in the context of C2.
+//
+// Check that DIBuilder processes the limited debug info case correctly, and doesn't add the same
+// local type to retainedNodes fields of both DISubprograms (C1 and C2).
+
+// FIXME: Should we ensure that DICompositeType is emitted in the same scope in both limited and
+// standalone modes?
----------------
jmorse wrote:

It does feel wrong that there's a difference; I think in the grand scheme of things though, this is an acceptable variation as part of the greater aim of fixing locally-scoped types. Presumably if this created difficulties for consumers, it would present itself when someone consumed compilation-units that were compiled with different flags?

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


More information about the llvm-commits mailing list