<br><br><div>On Tue Jan 14 2014 at 4:10:57 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: echristo<br>
Date: Tue Jan 14 18:04:29 2014<br>
New Revision: 199276<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=199276&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=199276&view=rev</a><br>
Log:<br>
Make sure we emit a relocation to the debug_ranges section in the<br>
presence of CU ranges.<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/<u></u>AsmPrinter/DwarfDebug.cpp<br>
    llvm/trunk/lib/CodeGen/<u></u>AsmPrinter/DwarfDebug.h<br>
    llvm/trunk/test/DebugInfo/X86/<u></u>cu-ranges.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<u></u>AsmPrinter/DwarfDebug.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=199276&r1=199275&r2=199276&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/lib/<u></u>CodeGen/AsmPrinter/DwarfDebug.<u></u>cpp?rev=199276&r1=199275&r2=<u></u>199276&view=diff</a><br>

==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/lib/CodeGen/<u></u>AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<u></u>AsmPrinter/DwarfDebug.cpp Tue Jan 14 18:04:29 2014<br>
@@ -209,6 +209,10 @@ DwarfDebug::DwarfDebug(<u></u>AsmPrinter *A, Mo<br>
   else<br>
     HasDwarfPubSections = DwarfPubSections == Enable;<br>
<br>
+  // For now only turn on CU ranges if we've explicitly asked for it<br>
+  // or we have -ffunction-sections enabled.<br></blockquote><div><br></div><div>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?<br><br>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?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  HasCURanges = DwarfCURanges || TargetMachine::<u></u>getFunctionSections();<br></blockquote><div><br></div><div>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)<br>
<br>& 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...)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
   DwarfVersion = DwarfVersionNumber<br>
                      ? DwarfVersionNumber<br>
                      : getDwarfVersionFromModule(MMI-<u></u>>getModule());<br>
@@ -1057,8 +1061,7 @@ void DwarfDebug::<u></u>finalizeModuleInfo() {<br>
       // FIXME: We should use ranges if we have multiple compile units or<br>
       // allow reordering of code ala .subsections_via_symbols in mach-o.<br>
       DwarfCompileUnit *U = SkCU ? SkCU : static_cast<DwarfCompileUnit *>(TheU);<br>
-      if ((DwarfCURanges || TargetMachine::<u></u>getFunctionSections()) &&<br>
-          TheU->getRanges().size())<br>
+      if (useCURanges() && TheU->getRanges().size())<br>
         addSectionLabel(Asm, U, U->getUnitDie(), dwarf::DW_AT_ranges,<br>
                         Asm->GetTempSymbol("cu_ranges"<u></u>, U->getUniqueID()),<br>
                         DwarfDebugRangeSectionSym);<br>
@@ -2910,7 +2913,7 @@ void DwarfDebug::emitDebugRanges() {<br>
     }<br>
<br>
     // Now emit a range for the CU itself.<br>
-    if (DwarfCURanges) {<br>
+    if (useCURanges()) {<br>
       Asm->OutStreamer.EmitLabel(<br>
           Asm->GetTempSymbol("cu_ranges"<u></u>, TheCU->getUniqueID()));<br>
       const SmallVectorImpl<RangeSpan> &Ranges = TheCU->getRanges();<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<u></u>AsmPrinter/DwarfDebug.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=199276&r1=199275&r2=199276&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/lib/<u></u>CodeGen/AsmPrinter/DwarfDebug.<u></u>h?rev=199276&r1=199275&r2=<u></u>199276&view=diff</a><br>

==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/lib/CodeGen/<u></u>AsmPrinter/DwarfDebug.h (original)<br>
+++ llvm/trunk/lib/CodeGen/<u></u>AsmPrinter/DwarfDebug.h Tue Jan 14 18:04:29 2014<br>
@@ -458,6 +458,9 @@ class DwarfDebug : public AsmPrinterHand<br>
   // Whether to emit the pubnames/pubtypes sections.<br>
   bool HasDwarfPubSections;<br>
<br>
+  // Whether or not to use AT_ranges for compilation units.<br>
+  bool HasCURanges;<br>
+<br>
   // Version of dwarf we're emitting.<br>
   unsigned DwarfVersion;<br>
<br>
@@ -733,6 +736,9 @@ public:<br>
   /// split dwarf proposal support.<br>
   bool useSplitDwarf() { return HasSplitDwarf; }<br>
<br>
+  /// \brief Returns whether or not to use AT_ranges for compilation units.<br>
+  bool useCURanges() { return HasCURanges; }<br></blockquote><div><br></div><div>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)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
   /// Returns the Dwarf Version.<br>
   unsigned getDwarfVersion() const { return DwarfVersion; }<br>
<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/<u></u>cu-ranges.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/cu-ranges.ll?rev=199276&r1=199275&r2=199276&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/test/<u></u>DebugInfo/X86/cu-ranges.ll?<u></u>rev=199276&r1=199275&r2=<u></u>199276&view=diff</a><br>

==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/test/DebugInfo/X86/<u></u>cu-ranges.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/<u></u>cu-ranges.ll Tue Jan 14 18:04:29 2014<br>
@@ -1,5 +1,6 @@<br>
 ; RUN: llc -split-dwarf=Enable -O0 %s -ffunction-sections -mtriple=x86_64-unknown-linux-<u></u>gnu -filetype=obj -o %t<br>
 ; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck --check-prefix=FUNCTION-<u></u>SECTIONS %s<br>
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=FUNCTION-<u></u>SECTIONS-RELOCS %s<br>
<br>
 ; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-<u></u>gnu -filetype=obj -o %t<br>
 ; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck --check-prefix=NO-FUNCTION-<u></u>SECTIONS %s<br>
@@ -12,6 +13,9 @@<br>
 ; With function sections enabled make sure that we have a DW_AT_ranges attribute.<br>
 ; FUNCTION-SECTIONS: DW_AT_ranges<br>
<br>
+; Check that we have a relocation against the .debug_ranges section.<br>
+; FUNCTION-SECTIONS-RELOCS: R_X86_64_32 .debug_ranges 0x0<br>
+<br>
 ; Without function sections enabled make sure that we have no DW_AT_ranges attribute.<br>
 ; NO-FUNCTION-SECTIONS-NOT: DW_AT_ranges<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</blockquote>