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

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 4 13:45:24 PDT 2023


================
@@ -559,37 +587,61 @@ void llvm::emitDWARF5AccelTable(
     default:
       continue;
     }
-    CUIndex[CU.index()] = Count++;
+    CUIndex[CU.index()] = CUCount++;
     assert(CU.index() == CU.value()->getUniqueID());
     const DwarfCompileUnit *MainCU =
         DD.useSplitDwarf() ? CU.value()->getSkeleton() : CU.value().get();
     CompUnits.push_back(MainCU->getLabelBegin());
   }
 
+  for (const auto &TU : enumerate(TUs)) {
+    switch (TU.value()->getCUNode()->getNameTableKind()) {
+    case DICompileUnit::DebugNameTableKind::Default:
+      break;
+    default:
+      continue;
+    }
+    TUIndex[&TU.value()->getUnitDie()] = TUCount++;
+    const DwarfTypeUnit *MainTU = TU.value().get();
+    TypeUnits.push_back(MainTU->getLabelBegin());
+  }
+
   if (CompUnits.empty())
     return;
 
   Asm->OutStreamer->switchSection(
       Asm->getObjFileLowering().getDwarfDebugNamesSection());
 
   Contents.finalize(Asm, "names");
+  dwarf::Form CUIndexForm =
+      DIEInteger::BestForm(/*IsSigned*/ false, CompUnits.size() - 1);
+  dwarf::Form TUIndexForm =
+      DIEInteger::BestForm(/*IsSigned*/ false, TypeUnits.size() - 1);
   Dwarf5AccelTableWriter<DWARF5AccelTableData>(
-      Asm, Contents, CompUnits,
-      [&](const DWARF5AccelTableData &Entry) {
+      Asm, Contents, CompUnits, TypeUnits,
+      [&](const DWARF5AccelTableData &Entry) -> GetIndexForEntryReturnType {
         const DIE *CUDie = Entry.getDie().getUnitDie();
----------------
dwblaikie wrote:

`CUDie` might be a misleading name now that this might be a TUDie instead - `UnitDie`?

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


More information about the llvm-commits mailing list