summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp7
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp18
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h6
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
OpenPOWER on IntegriCloud