diff options
author | David Blaikie <dblaikie@gmail.com> | 2021-01-25 16:15:14 -0800 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2021-01-25 16:24:35 -0800 |
commit | 70e251497c4e26f8cfd85e745459afff97c909ce (patch) | |
tree | d707eeb8aa1874969ff08b8f096ae47c05d62c8c | |
parent | c9466ede7e8797b7a6f1a09d1129230485649a4f (diff) | |
download | llvm-70e251497c4e26f8cfd85e745459afff97c909ce.zip llvm-70e251497c4e26f8cfd85e745459afff97c909ce.tar.gz llvm-70e251497c4e26f8cfd85e745459afff97c909ce.tar.bz2 |
DebugInfo: Generalize the .debug_addr minimization flag to pave the way for including other strategies
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 29 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 14 | ||||
-rw-r--r-- | llvm/test/DebugInfo/X86/ranges_always.ll | 2 |
3 files changed, 29 insertions, 16 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 12b6283..4626827 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -151,13 +151,18 @@ static cl::opt<LinkageNameOption> "Abstract subprograms")), cl::init(DefaultLinkageNames)); -static cl::opt<DefaultOnOff> AlwaysUseRangesInV5( - "always-use-ranges-in-v5", cl::Hidden, +static cl::opt<DwarfDebug::MinimizeAddrInV5> MinimizeAddrInV5Option( + "minimize-addr-in-v5", cl::Hidden, cl::desc("Always use DW_AT_ranges in DWARFv5 whenever it could allow more " "address pool entry sharing to reduce relocations/object size"), - cl::values(clEnumVal(Default, "Default for platform"), - clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")), - cl::init(Default)); + cl::values(clEnumValN(DwarfDebug::MinimizeAddrInV5::Default, "Default", + "Default address minimization strategy"), + clEnumValN(DwarfDebug::MinimizeAddrInV5::Ranges, "Ranges", + "Use rnglists for contiguous ranges if that allows " + "using a pre-existing base address"), + clEnumValN(DwarfDebug::MinimizeAddrInV5::Disabled, "Disabled", + "Stuff")), + cl::init(DwarfDebug::MinimizeAddrInV5::Default)); static constexpr unsigned ULEB128PadSize = 4; @@ -433,14 +438,12 @@ DwarfDebug::DwarfDebug(AsmPrinter *A) // Split DWARF would benefit object size significantly by trading reductions // in address pool usage for slightly increased range list encodings. if (DwarfVersion >= 5) { - if (AlwaysUseRangesInV5 == Default) { - // FIXME: In the future, enable this by default for Split DWARF where the - // tradeoff is more pronounced due to being able to offload the range - // lists to the dwo file and shrink object files/reduce relocations there. - AlwaysUseRanges = false; - } else { - AlwaysUseRanges = AlwaysUseRangesInV5 == Enable; - } + MinimizeAddr = MinimizeAddrInV5Option; + // FIXME: In the future, enable this by default for Split DWARF where the + // tradeoff is more pronounced due to being able to offload the range + // lists to the dwo file and shrink object files/reduce relocations there. + if (MinimizeAddr == MinimizeAddrInV5::Default) + MinimizeAddr = MinimizeAddrInV5::Disabled; } Asm->OutStreamer->getContext().setDwarfVersion(DwarfVersion); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index b3b8e62..df19ef4 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -378,8 +378,16 @@ class DwarfDebug : public DebugHandlerBase { /// Avoid using DW_OP_convert due to consumer incompatibilities. bool EnableOpConvert; +public: + enum class MinimizeAddrInV5 { + Default, + Disabled, + Ranges, + }; + +private: /// Force the use of DW_AT_ranges even for single-entry range lists. - bool AlwaysUseRanges = false; + MinimizeAddrInV5 MinimizeAddr = MinimizeAddrInV5::Disabled; /// DWARF5 Experimental Options /// @{ @@ -694,7 +702,9 @@ public: /// Returns whether range encodings should be used for single entry range /// lists. - bool alwaysUseRanges() const { return AlwaysUseRanges; } + bool alwaysUseRanges() const { + return MinimizeAddr == MinimizeAddrInV5::Ranges; + } /// Returns whether to use sections as labels rather than temp symbols. bool useSectionsAsReferences() const { diff --git a/llvm/test/DebugInfo/X86/ranges_always.ll b/llvm/test/DebugInfo/X86/ranges_always.ll index c361aea..230db20 100644 --- a/llvm/test/DebugInfo/X86/ranges_always.ll +++ b/llvm/test/DebugInfo/X86/ranges_always.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o - -always-use-ranges-in-v5=Enable \ +; RUN: llc -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o - -minimize-addr-in-v5=Ranges \ ; RUN: | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \ ; RUN: | FileCheck --implicit-check-not=DW_TAG --implicit-check-not=NULL --implicit-check-not=DW_AT_low_pc --implicit-check-not=DW_AT_high_pc --implicit-check-not=DW_AT_ranges %s |