diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2018-03-20 20:21:38 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2018-03-20 20:21:38 +0000 |
| commit | 858a7dd6d70bfed500e0e2a5137f25dd71b90f19 (patch) | |
| tree | 540c7ba9447aa89b785774d7258fc6a0de7d11e6 /llvm/lib | |
| parent | 04de0b43404030dc9636bdd45576e3fbe5f8e6af (diff) | |
| download | bcm5719-llvm-858a7dd6d70bfed500e0e2a5137f25dd71b90f19.tar.gz bcm5719-llvm-858a7dd6d70bfed500e0e2a5137f25dd71b90f19.zip | |
[DEBUGINFO] Add -no-dwarf-debug-ranges option.
Summary:
Added option -no-dwarf-debug-ranges option to disable emission of
.debug_ranges section.
Reviewers: probinson, echristo
Subscribers: aprantl, JDevlieghere, llvm-commits
Differential Revision: https://reviews.llvm.org/D44384
llvm-svn: 328030
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 18 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 6 |
3 files changed, 27 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 0ff1b5004d9..2cee47c04d8 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -410,9 +410,10 @@ void DwarfCompileUnit::addScopeRangeList(DIE &ScopeDIE, void DwarfCompileUnit::attachRangesOrLowHighPC( DIE &Die, SmallVector<RangeSpan, 2> Ranges) { - if (Ranges.size() == 1) { - const auto &single = Ranges.front(); - attachLowHighPC(Die, single.getStart(), single.getEnd()); + if (Ranges.size() == 1 || !DD->useRangesSection()) { + const RangeSpan &Front = Ranges.front(); + const RangeSpan &Back = Ranges.back(); + attachLowHighPC(Die, Front.getStart(), Back.getEnd()); } else addScopeRangeList(Die, std::move(Ranges)); } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index b9a17d5018c..58ef279a9f6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -128,6 +128,11 @@ static cl::opt<bool> cl::desc("Disable emission of DWARF pub sections."), cl::init(false)); +static cl::opt<bool> + NoDwarfRangesSection("no-dwarf-ranges-section", cl::Hidden, + cl::desc("Disable emission .debug_ranges section."), + cl::init(false)); + enum LinkageNameOption { DefaultLinkageNames, AllLinkageNames, @@ -316,6 +321,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) DwarfVersion = DwarfVersion ? DwarfVersion : dwarf::DWARF_VERSION; UsePubSections = !NoDwarfPubSections; + UseRangesSection = !NoDwarfRangesSection; // Work around a GDB bug. GDB doesn't support the standard opcode; // SCE doesn't support GNU's; LLDB prefers the standard opcode, which @@ -744,7 +750,7 @@ void DwarfDebug::finalizeModuleInfo() { // ranges for all subprogram DIEs for mach-o. DwarfCompileUnit &U = SkCU ? *SkCU : TheCU; if (unsigned NumRanges = TheCU.getRanges().size()) { - if (NumRanges > 1) + if (NumRanges > 1 && useRangesSection()) // 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 // location lists (see Section 2.6.2) and range lists (see Section @@ -1906,6 +1912,16 @@ void DwarfDebug::emitDebugRanges() { if (CUMap.empty()) return; + if (!useRangesSection()) { + assert(llvm::all_of( + CUMap, + [](const decltype(CUMap)::const_iterator::value_type &Pair) { + return Pair.second->getRangeLists().empty(); + }) && + "No debug ranges expected."); + return; + } + // Start the dwarf ranges section. Asm->OutStreamer->SwitchSection( Asm->getObjFileLowering().getDwarfRangesSection()); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index 56a1d633729..4459a5051e4 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -261,6 +261,9 @@ class DwarfDebug : public DebugHandlerBase { /// Whether to emit DWARF pub sections or not. bool UsePubSections = true; + /// Allow emission of .debug_ranges section. + bool UseRangesSection = true; + /// DWARF5 Experimental Options /// @{ bool HasDwarfAccelTables; @@ -507,6 +510,9 @@ public: /// Returns whether GNU oub sections should be emitted. bool usePubSections() const { return UsePubSections; } + /// Returns whether ranges section should be emitted. + bool useRangesSection() const { return UseRangesSection; } + // Experimental DWARF5 features. /// Returns whether or not to emit tables that dwarf consumers can |

