[llvm] r199276 - Make sure we emit a relocation to the debug_ranges section in the
dblaikie at gmail.com
dblaikie at gmail.com
Wed Jan 15 11:37:48 PST 2014
On Tue Jan 14 2014 at 4:10:57 PM, Eric Christopher <echristo at gmail.com>
wrote:
> Author: echristo
> Date: Tue Jan 14 18:04:29 2014
> New Revision: 199276
>
> URL: http://llvm.org/viewvc/llvm-project?rev=199276&view=rev
> Log:
> Make sure we emit a relocation to the debug_ranges section in the
> presence of CU ranges.
>
> Modified:
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
> llvm/trunk/test/DebugInfo/X86/cu-ranges.ll
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/DwarfDebug.cpp?rev=199276&r1=199275&r2=199276&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Jan 14 18:04:29
> 2014
> @@ -209,6 +209,10 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Mo
> else
> HasDwarfPubSections = DwarfPubSections == Enable;
>
> + // For now only turn on CU ranges if we've explicitly asked for it
> + // or we have -ffunction-sections enabled.
>
So where are we at the moment? No high_pc/low_pc on the CU at all, ever?
Then AT_ranges if enabled or function sections?
In theory we could save a few bytes per CU by using high_pc and low_pc if
DwarfCURanges was requested, but function sections weren't in use? Or do we
have a consumer that can't tolerate high_pc/low_pc?
> + HasCURanges = DwarfCURanges || TargetMachine::getFunctionSections();
>
Can we init this in the initializer list? (bonus points for then making the
member const - but we don't do that consistently at the moment, so eh)
& what's with "TargetMachine::getFunctionSections" - is that a constant?
Oh, I see it's a command line argument (I still don't really understand
which things use cl::opt, which things use API-level parameter passing, and
what the intended ideal state is there...)
> +
> DwarfVersion = DwarfVersionNumber
> ? DwarfVersionNumber
> : getDwarfVersionFromModule(MMI->getModule());
> @@ -1057,8 +1061,7 @@ void DwarfDebug::finalizeModuleInfo() {
> // FIXME: We should use ranges if we have multiple compile units or
> // allow reordering of code ala .subsections_via_symbols in mach-o.
> DwarfCompileUnit *U = SkCU ? SkCU : static_cast<DwarfCompileUnit
> *>(TheU);
> - if ((DwarfCURanges || TargetMachine::getFunctionSections()) &&
> - TheU->getRanges().size())
> + if (useCURanges() && TheU->getRanges().size())
> addSectionLabel(Asm, U, U->getUnitDie(), dwarf::DW_AT_ranges,
> Asm->GetTempSymbol("cu_ranges",
> U->getUniqueID()),
> DwarfDebugRangeSectionSym);
> @@ -2910,7 +2913,7 @@ void DwarfDebug::emitDebugRanges() {
> }
>
> // Now emit a range for the CU itself.
> - if (DwarfCURanges) {
> + if (useCURanges()) {
> Asm->OutStreamer.EmitLabel(
> Asm->GetTempSymbol("cu_ranges", TheCU->getUniqueID()));
> const SmallVectorImpl<RangeSpan> &Ranges = TheCU->getRanges();
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/DwarfDebug.h?rev=199276&r1=199275&r2=199276&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Jan 14 18:04:29
> 2014
> @@ -458,6 +458,9 @@ class DwarfDebug : public AsmPrinterHand
> // Whether to emit the pubnames/pubtypes sections.
> bool HasDwarfPubSections;
>
> + // Whether or not to use AT_ranges for compilation units.
> + bool HasCURanges;
> +
> // Version of dwarf we're emitting.
> unsigned DwarfVersion;
>
> @@ -733,6 +736,9 @@ public:
> /// split dwarf proposal support.
> bool useSplitDwarf() { return HasSplitDwarf; }
>
> + /// \brief Returns whether or not to use AT_ranges for compilation
> units.
> + bool useCURanges() { return HasCURanges; }
>
Bit arbitrarily confusing between "Has" and "use" - and is there any merit
in having an accessor that's only used from within the class anyway?
(rather than just directly accessing the member variable)
> +
> /// Returns the Dwarf Version.
> unsigned getDwarfVersion() const { return DwarfVersion; }
>
>
> Modified: llvm/trunk/test/DebugInfo/X86/cu-ranges.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> DebugInfo/X86/cu-ranges.ll?rev=199276&r1=199275&r2=199276&view=diff
> ============================================================
> ==================
> --- llvm/trunk/test/DebugInfo/X86/cu-ranges.ll (original)
> +++ llvm/trunk/test/DebugInfo/X86/cu-ranges.ll Tue Jan 14 18:04:29 2014
> @@ -1,5 +1,6 @@
> ; RUN: llc -split-dwarf=Enable -O0 %s -ffunction-sections
> -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
> ; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck
> --check-prefix=FUNCTION-SECTIONS %s
> +; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=FUNCTION-SECTIONS-RELOCS
> %s
>
> ; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-gnu
> -filetype=obj -o %t
> ; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck
> --check-prefix=NO-FUNCTION-SECTIONS %s
> @@ -12,6 +13,9 @@
> ; With function sections enabled make sure that we have a DW_AT_ranges
> attribute.
> ; FUNCTION-SECTIONS: DW_AT_ranges
>
> +; Check that we have a relocation against the .debug_ranges section.
> +; FUNCTION-SECTIONS-RELOCS: R_X86_64_32 .debug_ranges 0x0
> +
> ; Without function sections enabled make sure that we have no
> DW_AT_ranges attribute.
> ; NO-FUNCTION-SECTIONS-NOT: DW_AT_ranges
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140115/92b6d385/attachment.html>
More information about the llvm-commits
mailing list