llvm.org GIT mirror llvm / a49cbec
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 David Blaikie 5 years ago
1 changed file(s) with 47 addition(s) and 50 deletion(s). Raw diff Collapse all Expand all
540540
541541 // Handle anything that needs to be done on a per-unit basis after
542542 // all other generation.
543 for (const auto &TheU : getUnits()) {
543 for (const auto &P : CUMap) {
544 auto &TheCU = *P.second;
544545 // Emit DW_AT_containing_type attribute to connect types with their
545546 // vtable holding type.
546 TheU->constructContainingTypeDIEs();
547 TheCU.constructContainingTypeDIEs();
547548
548549 // Add CU specific attributes if we need to add any.
549 if (TheU->getUnitDie().getTag() == dwarf::DW_TAG_compile_unit) {
550 // If we're splitting the dwarf out now that we've got the entire
551 // CU then add the dwo id to it.
552 DwarfCompileUnit *SkCU = TheU->getSkeleton();
553 if (useSplitDwarf()) {
554 // Emit a unique identifier for this CU.
555 uint64_t ID = DIEHash(Asm).computeCUSignature(TheU->getUnitDie());
556 TheU->addUInt(TheU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
557 dwarf::DW_FORM_data8, ID);
558 SkCU->addUInt(SkCU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
559 dwarf::DW_FORM_data8, ID);
560
561 // We don't keep track of which addresses are used in which CU so this
562 // is a bit pessimistic under LTO.
563 if (!AddrPool.isEmpty())
564 SkCU->addSectionLabel(SkCU->getUnitDie(), dwarf::DW_AT_GNU_addr_base,
565 DwarfAddrSectionSym, DwarfAddrSectionSym);
566 if (!TheU->getRangeLists().empty())
567 SkCU->addSectionLabel(
568 SkCU->getUnitDie(), dwarf::DW_AT_GNU_ranges_base,
569 DwarfDebugRangeSectionSym, DwarfDebugRangeSectionSym);
570 }
571
572 // If we have code split among multiple sections or non-contiguous
573 // ranges of code then emit a DW_AT_ranges attribute on the unit that will
574 // remain in the .o file, otherwise add a DW_AT_low_pc.
575 // FIXME: We should use ranges allow reordering of code ala
576 // .subsections_via_symbols in mach-o. This would mean turning on
577 // ranges for all subprogram DIEs for mach-o.
578 DwarfCompileUnit &U =
579 SkCU ? *SkCU : static_cast(*TheU);
580 unsigned NumRanges = TheU->getRanges().size();
581 if (NumRanges) {
582 if (NumRanges > 1) {
583 U.addSectionLabel(U.getUnitDie(), dwarf::DW_AT_ranges,
584 Asm->GetTempSymbol("cu_ranges", U.getUniqueID()),
585 DwarfDebugRangeSectionSym);
586
587 // A DW_AT_low_pc attribute may also be specified in combination with
588 // DW_AT_ranges to specify the default base address for use in
589 // location lists (see Section 2.6.2) and range lists (see Section
590 // 2.17.3).
591 U.addUInt(U.getUnitDie(), dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
592 0);
593 } else {
594 RangeSpan &Range = TheU->getRanges().back();
595 U.attachLowHighPC(U.getUnitDie(), Range.getStart(), Range.getEnd());
596 }
550 // If we're splitting the dwarf out now that we've got the entire
551 // CU then add the dwo id to it.
552 auto *SkCU = TheCU.getSkeleton();
553 if (useSplitDwarf()) {
554 // Emit a unique identifier for this CU.
555 uint64_t ID = DIEHash(Asm).computeCUSignature(TheCU.getUnitDie());
556 TheCU.addUInt(TheCU.getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
557 dwarf::DW_FORM_data8, ID);
558 SkCU->addUInt(SkCU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
559 dwarf::DW_FORM_data8, ID);
560
561 // We don't keep track of which addresses are used in which CU so this
562 // is a bit pessimistic under LTO.
563 if (!AddrPool.isEmpty())
564 SkCU->addSectionLabel(SkCU->getUnitDie(), dwarf::DW_AT_GNU_addr_base,
565 DwarfAddrSectionSym, DwarfAddrSectionSym);
566 if (!TheCU.getRangeLists().empty())
567 SkCU->addSectionLabel(SkCU->getUnitDie(), dwarf::DW_AT_GNU_ranges_base,
568 DwarfDebugRangeSectionSym,
569 DwarfDebugRangeSectionSym);
570 }
571
572 // If we have code split among multiple sections or non-contiguous
573 // ranges of code then emit a DW_AT_ranges attribute on the unit that will
574 // remain in the .o file, otherwise add a DW_AT_low_pc.
575 // FIXME: We should use ranges allow reordering of code ala
576 // .subsections_via_symbols in mach-o. This would mean turning on
577 // ranges for all subprogram DIEs for mach-o.
578 DwarfCompileUnit &U = SkCU ? *SkCU : *TheCU;
579 unsigned NumRanges = TheCU.getRanges().size();
580 if (NumRanges) {
581 if (NumRanges > 1) {
582 U.addSectionLabel(U.getUnitDie(), dwarf::DW_AT_ranges,
583 Asm->GetTempSymbol("cu_ranges", U.getUniqueID()),
584 DwarfDebugRangeSectionSym);
585
586 // A DW_AT_low_pc attribute may also be specified in combination with
587 // DW_AT_ranges to specify the default base address for use in
588 // location lists (see Section 2.6.2) and range lists (see Section
589 // 2.17.3).
590 U.addUInt(U.getUnitDie(), dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, 0);
591 } else {
592 RangeSpan &Range = TheCU.getRanges().back();
593 U.attachLowHighPC(U.getUnitDie(), Range.getStart(), Range.getEnd());
597594 }
598595 }
599596 }