<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 24, 2014 at 3:40 AM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: echristo<br>
Date: Fri Jan 24 05:40:29 2014<br>
New Revision: 199990<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=199990&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=199990&view=rev</a><br>
Log:<br>
Use DW_AT_high_pc and DW_AT_low_pc for the high and low pc for a<br>
compile unit. Make these relocations on the platforms that need<br>
relocations and add a routine to ensure that we don't put the<br>
addresses in an offset table for split dwarf.<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h<br>
    llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll<br>
    llvm/trunk/test/DebugInfo/X86/fission-cu.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=199990&r1=199989&r2=199990&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=199990&r1=199989&r2=199990&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Jan 24 05:40:29 2014<br>
@@ -187,6 +187,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Mo<br>
   DwarfAddrSectionSym = 0;<br>
   DwarfAbbrevDWOSectionSym = DwarfStrDWOSectionSym = 0;<br>
   FunctionBeginSym = FunctionEndSym = 0;<br>
+  TextSectionBeginSym = TextSectionEndSym = 0;<br></blockquote><div><br></div><div>Rather than keeping track of two new symbols - can we just form this from the ranges data we already have? (the begin label of the first range and the end label of the last)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
   CurFn = 0;<br>
   CurMI = 0;<br>
<br>
@@ -1061,9 +1062,12 @@ void DwarfDebug::finalizeModuleInfo() {<br>
         addSectionLabel(Asm, U, U->getUnitDie(), dwarf::DW_AT_ranges,<br>
                         Asm->GetTempSymbol("cu_ranges", U->getUniqueID()),<br>
                         DwarfDebugRangeSectionSym);<br>
-      else<br>
-        U->addUInt(U->getUnitDie(), dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,<br>
-                   0);<br>
+      else {<br>
+        U->addLocalLabelAddress(U->getUnitDie(), dwarf::DW_AT_low_pc,<br>
+                                TextSectionBeginSym);<br>
+        U->addLocalLabelAddress(U->getUnitDie(), dwarf::DW_AT_high_pc,<br>
+                                TextSectionEndSym);<br></blockquote><div><br></div><div>Be sort of nice if this came out in the wash & we didn't have to know at the call-site that we were adding something to the non-dwo unit. But yeah, short of having more derived classes in the DwarfUnit hierarchy (and it's sort of orthogonal to that - since it applies to type and compile units equally... ) I'm not sure how to make that happen.<br>
<br>Well, something to mull over/keep in mind.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+      }<br>
     }<br>
   }<br>
<br>
@@ -1117,6 +1121,10 @@ void DwarfDebug::endSections() {<br>
       Sym = Asm->GetTempSymbol("debug_end", ID);<br>
       Asm->OutStreamer.SwitchSection(Section);<br>
       Asm->OutStreamer.EmitLabel(Sym);<br>
+      // If this is the end of the text section keep track of where the end of<br>
+      // the section is so that we can use it later.<br>
+      if (Section == Asm->getObjFileLowering().getTextSection())<br>
+        TextSectionEndSym = Sym;<br>
     }<br>
<br>
     // Insert a final terminator.<br>
@@ -2012,6 +2020,8 @@ void DwarfDebug::emitSectionLabels() {<br>
<br>
   DwarfDebugLocSectionSym =<br>
       emitSectionSym(Asm, TLOF.getDwarfLocSection(), "section_debug_loc");<br>
+<br>
+  TextSectionBeginSym = emitSectionSym(Asm, TLOF.getTextSection(), "text_begin");<br>
 }<br>
<br>
 // Recursively emits a debug information entry.<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=199990&r1=199989&r2=199990&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=199990&r1=199989&r2=199990&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Fri Jan 24 05:40:29 2014<br>
@@ -432,6 +432,7 @@ class DwarfDebug : public AsmPrinterHand<br>
   MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym;<br>
   MCSymbol *DwarfStrDWOSectionSym;<br>
   MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;<br>
+  MCSymbol *TextSectionBeginSym, *TextSectionEndSym;<br>
<br>
   // As an optimization, there is no need to emit an entry in the directory<br>
   // table for the same directory as DW_AT_comp_dir.<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=199990&r1=199989&r2=199990&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=199990&r1=199989&r2=199990&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Fri Jan 24 05:40:29 2014<br>
@@ -266,21 +266,32 @@ void DwarfUnit::addSectionOffset(DIE *Di<br>
 ///<br>
 void DwarfCompileUnit::addLabelAddress(DIE *Die, dwarf::Attribute Attribute,<br>
                                        MCSymbol *Label) {<br>
+  if (!DD->useSplitDwarf())<br>
+    return addLocalLabelAddress(Die, Attribute, Label);<br>
+<br>
+  if (Label)<br>
+    DD->addArangeLabel(SymbolCU(this, Label));<br>
+<br>
+  unsigned idx = DU->getAddrPoolIndex(Label);<br>
+  DIEValue *Value = new (DIEValueAllocator) DIEInteger(idx);<br>
+  Die->addValue(Attribute, dwarf::DW_FORM_GNU_addr_index, Value);<br>
+}<br>
+<br>
+/// addLocalLabelAddress - Add a dwarf label attribute data and value using<br>
+/// DW_FORM_addr only.<br>
+///<br>
+void DwarfCompileUnit::addLocalLabelAddress(DIE *Die,<br>
+                                            dwarf::Attribute Attribute,<br>
+                                            MCSymbol *Label) {<br>
   if (Label)<br>
     DD->addArangeLabel(SymbolCU(this, Label));<br>
<br>
-  if (!DD->useSplitDwarf()) {<br>
-    if (Label) {<br>
-      DIEValue *Value = new (DIEValueAllocator) DIELabel(Label);<br>
-      Die->addValue(Attribute, dwarf::DW_FORM_addr, Value);<br>
-    } else {<br>
-      DIEValue *Value = new (DIEValueAllocator) DIEInteger(0);<br>
-      Die->addValue(Attribute, dwarf::DW_FORM_addr, Value);<br>
-    }<br>
+  if (Label) {<br>
+    DIEValue *Value = new (DIEValueAllocator) DIELabel(Label);<br>
+    Die->addValue(Attribute, dwarf::DW_FORM_addr, Value);<br>
   } else {<br>
-    unsigned idx = DU->getAddrPoolIndex(Label);<br>
-    DIEValue *Value = new (DIEValueAllocator) DIEInteger(idx);<br>
-    Die->addValue(Attribute, dwarf::DW_FORM_GNU_addr_index, Value);<br>
+    DIEValue *Value = new (DIEValueAllocator) DIEInteger(0);<br>
+    Die->addValue(Attribute, dwarf::DW_FORM_addr, Value);<br>
   }<br>
 }<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=199990&r1=199989&r2=199990&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=199990&r1=199989&r2=199990&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Fri Jan 24 05:40:29 2014<br>
@@ -545,6 +545,11 @@ public:<br>
   /// addLabelAddress - Add a dwarf label attribute data and value using<br>
   /// either DW_FORM_addr or DW_FORM_GNU_addr_index.<br>
   void addLabelAddress(DIE *Die, dwarf::Attribute Attribute, MCSymbol *Label);<br>
+<br>
+  /// addLocalLabelAddress - Add a dwarf label attribute data and value using<br>
+  /// DW_FORM_addr only.<br>
+  void addLocalLabelAddress(DIE *Die, dwarf::Attribute Attribute,<br>
+                            MCSymbol *Label);<br>
 };<br>
<br>
 class DwarfTypeUnit : public DwarfUnit {<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll?rev=199990&r1=199989&r2=199990&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll?rev=199990&r1=199989&r2=199990&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll Fri Jan 24 05:40:29 2014<br>
@@ -7,15 +7,15 @@<br>
 ; first check that we have a TAG_subprogram at a given offset and it has<br>
 ; AT_inline.<br>
<br>
-; CHECK: 0x0000011c:   DW_TAG_subprogram [17]<br>
+; CHECK: 0x00000124:   DW_TAG_subprogram [17]<br>
 ; CHECK-NEXT:     DW_AT_specification<br>
 ; CHECK-NEXT:     DW_AT_inline<br>
<br>
<br>
 ; and then that a TAG_subprogram refers to it with AT_abstract_origin.<br>
<br>
-; CHECK: 0x0000015d:   DW_TAG_subprogram [19]<br>
-; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4]    (cu + 0x011c => {0x0000011c})<br>
+; CHECK: 0x00000165:   DW_TAG_subprogram [19]<br>
+; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4]    (cu + 0x0124 => {0x00000124})<br>
<br>
 define i32 @_ZN17nsAutoRefCnt7ReleaseEv() {<br>
 entry:<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/fission-cu.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/fission-cu.ll?rev=199990&r1=199989&r2=199990&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/fission-cu.ll?rev=199990&r1=199989&r2=199990&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/fission-cu.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/fission-cu.ll Fri Jan 24 05:40:29 2014<br>
@@ -109,6 +109,8 @@<br>
 ; OBJ-NEXT: R_X86_64_32 .debug_str<br>
 ; OBJ-NEXT: R_X86_64_32 .debug_addr<br>
 ; OBJ-NEXT: R_X86_64_32 .debug_str<br>
+; OBJ-NEXT: R_X86_64_64 .text 0x0<br>
+; OBJ-NEXT: R_X86_64_64 .text 0x0<br>
 ; OBJ-NEXT: }<br>
 ; OBJ: .debug_aranges<br>
 ; OBJ-NEXT: R_X86_64_32 .debug_info 0x0<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">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/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>