summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2018-07-26 03:21:40 +0000
committerAlex Lorenz <arphaman@gmail.com>2018-07-26 03:21:40 +0000
commit7d808c19ff5e4610f8bd8c1714a0dab2d66c882e (patch)
tree30c53ce519a948f37b5ec72bd32e59c5837f92da /llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parent370bdd3a0f12629789d3b18b4bea178ee5cf2a23 (diff)
downloadbcm5719-llvm-7d808c19ff5e4610f8bd8c1714a0dab2d66c882e.tar.gz
bcm5719-llvm-7d808c19ff5e4610f8bd8c1714a0dab2d66c882e.zip
Revert r337981: it breaks the debuginfo-tests
This commit caused a regression in the debuginfo-tests: FAIL: debuginfo-tests :: apple-accel.cpp (40748 of 46595) llvm-svn: 337997
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp81
1 files changed, 47 insertions, 34 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index caf266f6870..f1e61b488a2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -820,10 +820,6 @@ void DwarfDebug::finalizeModuleInfo() {
U.attachRangesOrLowHighPC(U.getUnitDie(), TheCU.takeRanges());
}
- if (getDwarfVersion() >= 5 && !useSplitDwarf() &&
- !U.getRangeLists().empty())
- U.addRnglistsBase();
-
auto *CUNode = cast<DICompileUnit>(P.first);
// If compile Unit has macros, emit "DW_AT_macro_info" attribute.
if (CUNode->getMacros())
@@ -2090,10 +2086,23 @@ static void emitRangeList(AsmPrinter *Asm, DwarfCompileUnit *CU,
}
}
-// Emit the header of a DWARF 5 range list table. Returns the symbol that
-// designates the end of the table for the caller to emit when the table is
-// complete.
-static MCSymbol *emitRnglistsTableHeader(AsmPrinter *Asm, DwarfFile &Holder) {
+void DwarfDebug::emitDebugRnglists() {
+
+ // Don't emit a rangelist table if there are no ranges.
+ if (llvm::all_of(CUMap,
+ [](const decltype(CUMap)::const_iterator::value_type &Pair) {
+ DwarfCompileUnit *TheCU = Pair.second;
+ if (auto *Skel = TheCU->getSkeleton())
+ TheCU = Skel;
+ return TheCU->getRangeLists().empty();
+ }))
+ return;
+
+ assert(getDwarfVersion() >= 5 && "Dwarf version must be 5 or greater");
+ // FIXME: As long as we don't support DW_RLE_base_addrx, we cannot generate
+ // any tables in the .debug_rnglists.dwo section.
+ Asm->OutStreamer->SwitchSection(
+ Asm->getObjFileLowering().getDwarfRnglistsSection());
// The length is described by a starting label right after the length field
// and an end label.
MCSymbol *TableStart = Asm->createTempSymbol("debug_rnglist_table_start");
@@ -2102,52 +2111,56 @@ static MCSymbol *emitRnglistsTableHeader(AsmPrinter *Asm, DwarfFile &Holder) {
Asm->EmitLabelDifference(TableEnd, TableStart, 4);
Asm->OutStreamer->EmitLabel(TableStart);
// Version number (DWARF v5 and later).
- Asm->emitInt16(Asm->OutStreamer->getContext().getDwarfVersion());
+ Asm->emitInt16(getDwarfVersion());
// Address size.
Asm->emitInt8(Asm->MAI->getCodePointerSize());
// Segment selector size.
Asm->emitInt8(0);
- MCSymbol *RnglistTableBaseSym = Holder.getRnglistsTableBaseSym();
+ MCSymbol *RnglistTableBaseSym =
+ (useSplitDwarf() ? SkeletonHolder : InfoHolder).getRnglistsTableBaseSym();
// FIXME: Generate the offsets table and use DW_FORM_rnglistx with the
// DW_AT_ranges attribute. Until then set the number of offsets to 0.
Asm->emitInt32(0);
Asm->OutStreamer->EmitLabel(RnglistTableBaseSym);
- return TableEnd;
+
+ // Emit the individual range lists.
+ for (const auto &I : CUMap) {
+ DwarfCompileUnit *TheCU = I.second;
+ if (auto *Skel = TheCU->getSkeleton())
+ TheCU = Skel;
+ for (const RangeSpanList &List : TheCU->getRangeLists())
+ emitRangeList(Asm, TheCU, List);
+ }
+
+ Asm->OutStreamer->EmitLabel(TableEnd);
}
-/// Emit address ranges into the .debug_ranges section or into the DWARF v5
-/// .debug_rnglists section.
+/// Emit address ranges into the .debug_ranges section or DWARF v5 rangelists
+/// into the .debug_rnglists section.
void DwarfDebug::emitDebugRanges() {
if (CUMap.empty())
return;
- auto NoRangesPresent = [this]() {
- return llvm::all_of(
- CUMap, [](const decltype(CUMap)::const_iterator::value_type &Pair) {
- return Pair.second->getRangeLists().empty();
- });
- };
-
if (!useRangesSection()) {
- assert(NoRangesPresent() && "No debug ranges expected.");
+ assert(llvm::all_of(
+ CUMap,
+ [](const decltype(CUMap)::const_iterator::value_type &Pair) {
+ return Pair.second->getRangeLists().empty();
+ }) &&
+ "No debug ranges expected.");
return;
}
- if (NoRangesPresent())
+ if (getDwarfVersion() >= 5) {
+ emitDebugRnglists();
return;
+ }
// Start the dwarf ranges section.
- MCSymbol *TableEnd = nullptr;
- if (getDwarfVersion() >= 5) {
- Asm->OutStreamer->SwitchSection(
- Asm->getObjFileLowering().getDwarfRnglistsSection());
- TableEnd = emitRnglistsTableHeader(Asm, useSplitDwarf() ? SkeletonHolder
- : InfoHolder);
- } else
- Asm->OutStreamer->SwitchSection(
- Asm->getObjFileLowering().getDwarfRangesSection());
+ Asm->OutStreamer->SwitchSection(
+ Asm->getObjFileLowering().getDwarfRangesSection());
// Grab the specific ranges for the compile units in the module.
for (const auto &I : CUMap) {
@@ -2160,9 +2173,6 @@ void DwarfDebug::emitDebugRanges() {
for (const RangeSpanList &List : TheCU->getRangeLists())
emitRangeList(Asm, TheCU, List);
}
-
- if (TableEnd)
- Asm->OutStreamer->EmitLabel(TableEnd);
}
void DwarfDebug::handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U) {
@@ -2238,6 +2248,9 @@ void DwarfDebug::initSkeletonUnit(const DwarfUnit &U, DIE &Die,
SkeletonHolder.addUnit(std::move(NewU));
}
+// This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+// DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+// DW_AT_addr_base, DW_AT_ranges_base or DW_AT_rnglists_base.
DwarfCompileUnit &DwarfDebug::constructSkeletonCU(const DwarfCompileUnit &CU) {
auto OwnedUnit = llvm::make_unique<DwarfCompileUnit>(
OpenPOWER on IntegriCloud