[llvm] [LLVM][DWARF] Add support for monolithic types in .debug_names (PR #70515)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 1 17:06:28 PDT 2023
================
@@ -562,36 +596,53 @@ 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 : TUSymbols) {
+ TUIndex[TU.UniqueID] = TUCount++;
+ TypeUnits.push_back(TU.Label);
+ }
+
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) {
- return CUIndex[Entry.getUnitID()];
+ Asm, Contents, CompUnits, TypeUnits,
+ [&](const DWARF5AccelTableData &Entry) -> GetIndexForEntryReturnType {
+ GetIndexForEntryReturnType Index = std::nullopt;
+ if (Entry.isTU())
+ Index = {TUIndex[Entry.getUnitID()],
+ {dwarf::DW_IDX_type_unit, TUIndexForm}};
+ else if (CUIndex.size() > 1)
+ Index = {CUIndex[Entry.getUnitID()],
+ {dwarf::DW_IDX_compile_unit, CUIndexForm}};
+ return Index;
----------------
dwblaikie wrote:
Did the extra {} not work here? (seems you ended up with `return std::optional<..>(...);` which is a bit long/verbose/hard to read)
https://github.com/llvm/llvm-project/pull/70515
More information about the llvm-commits
mailing list