Just iterate the DwarfCompileUnits rather than trying to filter them out of the list of all units.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221034 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2014-11-01 01:11:19 +00:00
parent bf29eb3ad1
commit a49cbece54

View File

@ -541,60 +541,57 @@ void DwarfDebug::finalizeModuleInfo() {
// Handle anything that needs to be done on a per-unit basis after // Handle anything that needs to be done on a per-unit basis after
// all other generation. // all other generation.
for (const auto &TheU : getUnits()) { for (const auto &P : CUMap) {
auto &TheCU = *P.second;
// Emit DW_AT_containing_type attribute to connect types with their // Emit DW_AT_containing_type attribute to connect types with their
// vtable holding type. // vtable holding type.
TheU->constructContainingTypeDIEs(); TheCU.constructContainingTypeDIEs();
// Add CU specific attributes if we need to add any. // Add CU specific attributes if we need to add any.
if (TheU->getUnitDie().getTag() == dwarf::DW_TAG_compile_unit) { // If we're splitting the dwarf out now that we've got the entire
// If we're splitting the dwarf out now that we've got the entire // CU then add the dwo id to it.
// CU then add the dwo id to it. auto *SkCU = TheCU.getSkeleton();
DwarfCompileUnit *SkCU = TheU->getSkeleton(); if (useSplitDwarf()) {
if (useSplitDwarf()) { // Emit a unique identifier for this CU.
// Emit a unique identifier for this CU. uint64_t ID = DIEHash(Asm).computeCUSignature(TheCU.getUnitDie());
uint64_t ID = DIEHash(Asm).computeCUSignature(TheU->getUnitDie()); TheCU.addUInt(TheCU.getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
TheU->addUInt(TheU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id, dwarf::DW_FORM_data8, ID);
dwarf::DW_FORM_data8, ID); SkCU->addUInt(SkCU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
SkCU->addUInt(SkCU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id, dwarf::DW_FORM_data8, ID);
dwarf::DW_FORM_data8, ID);
// We don't keep track of which addresses are used in which CU so this // We don't keep track of which addresses are used in which CU so this
// is a bit pessimistic under LTO. // is a bit pessimistic under LTO.
if (!AddrPool.isEmpty()) if (!AddrPool.isEmpty())
SkCU->addSectionLabel(SkCU->getUnitDie(), dwarf::DW_AT_GNU_addr_base, SkCU->addSectionLabel(SkCU->getUnitDie(), dwarf::DW_AT_GNU_addr_base,
DwarfAddrSectionSym, DwarfAddrSectionSym); DwarfAddrSectionSym, DwarfAddrSectionSym);
if (!TheU->getRangeLists().empty()) if (!TheCU.getRangeLists().empty())
SkCU->addSectionLabel( SkCU->addSectionLabel(SkCU->getUnitDie(), dwarf::DW_AT_GNU_ranges_base,
SkCU->getUnitDie(), dwarf::DW_AT_GNU_ranges_base, DwarfDebugRangeSectionSym,
DwarfDebugRangeSectionSym, DwarfDebugRangeSectionSym); DwarfDebugRangeSectionSym);
} }
// If we have code split among multiple sections or non-contiguous // If we have code split among multiple sections or non-contiguous
// ranges of code then emit a DW_AT_ranges attribute on the unit that will // ranges of code then emit a DW_AT_ranges attribute on the unit that will
// remain in the .o file, otherwise add a DW_AT_low_pc. // remain in the .o file, otherwise add a DW_AT_low_pc.
// FIXME: We should use ranges allow reordering of code ala // FIXME: We should use ranges allow reordering of code ala
// .subsections_via_symbols in mach-o. This would mean turning on // .subsections_via_symbols in mach-o. This would mean turning on
// ranges for all subprogram DIEs for mach-o. // ranges for all subprogram DIEs for mach-o.
DwarfCompileUnit &U = DwarfCompileUnit &U = SkCU ? *SkCU : *TheCU;
SkCU ? *SkCU : static_cast<DwarfCompileUnit &>(*TheU); unsigned NumRanges = TheCU.getRanges().size();
unsigned NumRanges = TheU->getRanges().size(); if (NumRanges) {
if (NumRanges) { if (NumRanges > 1) {
if (NumRanges > 1) { U.addSectionLabel(U.getUnitDie(), dwarf::DW_AT_ranges,
U.addSectionLabel(U.getUnitDie(), dwarf::DW_AT_ranges, Asm->GetTempSymbol("cu_ranges", U.getUniqueID()),
Asm->GetTempSymbol("cu_ranges", U.getUniqueID()), DwarfDebugRangeSectionSym);
DwarfDebugRangeSectionSym);
// A DW_AT_low_pc attribute may also be specified in combination with // A DW_AT_low_pc attribute may also be specified in combination with
// DW_AT_ranges to specify the default base address for use in // DW_AT_ranges to specify the default base address for use in
// location lists (see Section 2.6.2) and range lists (see Section // location lists (see Section 2.6.2) and range lists (see Section
// 2.17.3). // 2.17.3).
U.addUInt(U.getUnitDie(), dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, U.addUInt(U.getUnitDie(), dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, 0);
0); } else {
} else { RangeSpan &Range = TheCU.getRanges().back();
RangeSpan &Range = TheU->getRanges().back(); U.attachLowHighPC(U.getUnitDie(), Range.getStart(), Range.getEnd());
U.attachLowHighPC(U.getUnitDie(), Range.getStart(), Range.getEnd());
}
} }
} }
} }