summaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp56
1 files changed, 24 insertions, 32 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index a30e8bbd95..acb25ccaaf 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -773,12 +773,6 @@ DwarfCompileUnit *DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
DIUnit.getLanguage());
NewCU->addString(Die, dwarf::DW_AT_name, FN);
- // 2.17.1 requires that we use DW_AT_low_pc for a single entry point
- // into an entity. We're using 0 (or a NULL label) for this. For
- // split dwarf it's in the skeleton CU so omit it here.
- if (!useSplitDwarf())
- NewCU->addLabelAddress(Die, dwarf::DW_AT_low_pc, NULL);
-
// Define start line table label for each Compile Unit.
MCSymbol *LineTableStartSym =
Asm->GetTempSymbol("line_table_start", NewCU->getUniqueID());
@@ -831,11 +825,11 @@ DwarfCompileUnit *DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
NewCU->initSection(
useSplitDwarf() ? Asm->getObjFileLowering().getDwarfInfoDWOSection()
: Asm->getObjFileLowering().getDwarfInfoSection(),
- // FIXME: This is subtle (using the info section even when
- // this CU is in the dwo section) and necessary for the
- // current arange code - ideally it should iterate
- // skeleton units, not full units, if it's going to reference skeletons
- DwarfInfoSectionSym);
+ useSplitDwarf() ? DwarfInfoDWOSectionSym : DwarfInfoSectionSym);
+
+ // If we're splitting the dwarf then construct the skeleton CU now.
+ if (useSplitDwarf())
+ NewCU->setSkeleton(constructSkeletonCU(NewCU));
CUMap.insert(std::make_pair(DIUnit, NewCU));
CUDieMap.insert(std::make_pair(Die, NewCU));
@@ -1082,7 +1076,9 @@ void DwarfDebug::finalizeModuleInfo() {
// 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
- // CU then construct a skeleton CU based upon it.
+ // CU then add the dwo id to it.
+ DwarfCompileUnit *SkCU =
+ static_cast<DwarfCompileUnit *>(TheU->getSkeleton());
if (useSplitDwarf()) {
// This should be a unique identifier when we want to build .dwp files.
uint64_t ID = 0;
@@ -1092,19 +1088,21 @@ void DwarfDebug::finalizeModuleInfo() {
}
TheU->addUInt(TheU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
dwarf::DW_FORM_data8, ID);
- // Now construct the skeleton CU associated.
- DwarfCompileUnit *SkCU =
- constructSkeletonCU(static_cast<DwarfCompileUnit *>(TheU));
SkCU->addUInt(SkCU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
dwarf::DW_FORM_data8, ID);
- } else {
- // Attribute if we've emitted a range list for the compile unit, this
- // will get constructed for the skeleton CU separately if we have one.
- if (DwarfCURanges && TheU->getRanges().size())
- addSectionLabel(Asm, TheU, TheU->getUnitDie(), dwarf::DW_AT_ranges,
- Asm->GetTempSymbol("cu_ranges", TheU->getUniqueID()),
- DwarfDebugRangeSectionSym);
}
+
+ // If we've requested ranges and have them emit a DW_AT_ranges attribute
+ // on the unit that will remain in the .o file, otherwise add a DW_AT_low_pc.
+ // FIXME: Also add a high pc if we can.
+ // FIXME: We should use ranges if we have multiple compile units.
+ DwarfCompileUnit *U = SkCU ? SkCU : static_cast<DwarfCompileUnit *>(TheU);
+ if (DwarfCURanges && TheU->getRanges().size())
+ addSectionLabel(Asm, U, U->getUnitDie(), dwarf::DW_AT_ranges,
+ Asm->GetTempSymbol("cu_ranges", U->getUniqueID()),
+ DwarfDebugRangeSectionSym);
+ else
+ U->addUInt(U->getUnitDie(), dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, 0);
}
}
@@ -2007,6 +2005,9 @@ void DwarfDebug::emitSectionLabels() {
// Dwarf sections base addresses.
DwarfInfoSectionSym =
emitSectionSym(Asm, TLOF.getDwarfInfoSection(), "section_info");
+ if (useSplitDwarf())
+ DwarfInfoDWOSectionSym =
+ emitSectionSym(Asm, TLOF.getDwarfInfoDWOSection(), "section_info_dwo");
DwarfAbbrevSectionSym =
emitSectionSym(Asm, TLOF.getDwarfAbbrevSection(), "section_abbrev");
if (useSplitDwarf())
@@ -2872,7 +2873,7 @@ void DwarfDebug::emitDebugARanges() {
Asm->OutStreamer.AddComment("DWARF Arange version number");
Asm->EmitInt16(dwarf::DW_ARANGES_VERSION);
Asm->OutStreamer.AddComment("Offset Into Debug Info Section");
- Asm->EmitSectionOffset(CU->getLabelBegin(), CU->getSectionSym());
+ Asm->EmitSectionOffset(CU->getLocalLabelBegin(), CU->getLocalSectionSym());
Asm->OutStreamer.AddComment("Address Size (in bytes)");
Asm->EmitInt8(PtrSize);
Asm->OutStreamer.AddComment("Segment Size (in bytes)");
@@ -2997,15 +2998,6 @@ DwarfCompileUnit *DwarfDebug::constructSkeletonCU(const DwarfCompileUnit *CU) {
else
NewCU->addSectionOffset(Die, dwarf::DW_AT_GNU_addr_base, 0);
- // Attribute if we've emitted a range list for the compile unit, this
- // will get constructed for the skeleton CU separately if we have one.
- if (DwarfCURanges && CU->getRanges().size())
- addSectionLabel(Asm, NewCU, Die, dwarf::DW_AT_ranges,
- Asm->GetTempSymbol("cu_ranges", CU->getUniqueID()),
- DwarfDebugRangeSectionSym);
- else
- NewCU->addUInt(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, 0);
-
// DW_AT_stmt_list is a offset of line number information for this
// compile unit in debug_line section.
// FIXME: Should handle multiple compile units.