[llvm] [LLVM][DWARF] Add support for monolithic types in .debug_names (PR #70515)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 13:58:00 PDT 2023


================
@@ -3552,8 +3564,15 @@ void DwarfDebug::addAccelNameImpl(const DICompileUnit &CU,
     AppleAccel.addName(Ref, Die);
     break;
   case AccelTableKind::Dwarf: {
-    DwarfCompileUnit *DCU = CUMap.lookup(&CU);
-    AccelDebugNames.addName(Ref, Die, *DCU);
+    // The type unit can be discarded, so need to add references to final
+    // acceleration table once we know it's complete and we emit it.
+    if (TypeUnitsUnderConstruction.empty()) {
+      DwarfCompileUnit *Unit = CUMap.lookup(&CU);
+      AccelDebugNames.addName(Ref, Die, *Unit);
+    } else {
+      DwarfTypeUnit *Unit = TypeUnitsUnderConstruction.back().first.get();
+      AccelTypeUntsDebugNames.addName(Ref, Die, *Unit);
+    }
----------------
dwblaikie wrote:

This could /possibly/ be handled by having a pointer member of DwarfDebug that points to the "current" name table - pointing to the type unit table when type units are being built, and pointing to the CU name table otherwise.

Also - I'm not sure this condition is sufficient - there are times when we might be constructing type units, but pass back into a CU context (eg: a type with linkage that references a typ ewithout linkage:
```
namespace {
struct t1 { };
}
struct t2 {
  t1 v1;
};
```

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


More information about the llvm-commits mailing list