[llvm] r204672 - DebugInfo: Add DW_AT_GNU_ranges_base to skeleton CUs

David Blaikie dblaikie at gmail.com
Mon Mar 24 14:31:35 PDT 2014


Author: dblaikie
Date: Mon Mar 24 16:31:35 2014
New Revision: 204672

URL: http://llvm.org/viewvc/llvm-project?rev=204672&view=rev
Log:
DebugInfo: Add DW_AT_GNU_ranges_base to skeleton CUs

This is used to avoid relocations in the dwo file by allowing
DW_AT_ranges specified in debug_info.dwo to be relative to this base
address. (r204667 implements the base-relative DW_AT_ranges side of
this)

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/test/DebugInfo/X86/fission-cu.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=204672&r1=204671&r2=204672&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Mar 24 16:31:35 2014
@@ -2651,8 +2651,7 @@ void DwarfDebug::initSkeletonUnit(const
 
 // This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
 // DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
-// DW_AT_ranges_base, DW_AT_addr_base.
-// TODO: Implement DW_AT_ranges_base.
+// DW_AT_addr_base, DW_AT_ranges_base.
 DwarfCompileUnit *DwarfDebug::constructSkeletonCU(const DwarfCompileUnit *CU) {
 
   DIE *Die = new DIE(dwarf::DW_TAG_compile_unit);
@@ -2667,10 +2666,16 @@ DwarfCompileUnit *DwarfDebug::constructS
 
   // Relocate to the beginning of the addr_base section, else 0 for the
   // beginning of the one for this compile unit.
-  if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
+  // We could shave off some space if we deferred adding these attributes until
+  // the end of the CU to see if we have a non-empty debug_addr and debug_ranges
+  // sections so we don't bother with extra attributes and relocations.
+  if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) {
     NewCU->addSectionLabel(Die, dwarf::DW_AT_GNU_addr_base, DwarfAddrSectionSym);
-  else
+    NewCU->addSectionLabel(Die, dwarf::DW_AT_GNU_ranges_base, DwarfDebugRangeSectionSym);
+  } else {
     NewCU->addSectionOffset(Die, dwarf::DW_AT_GNU_addr_base, 0);
+    NewCU->addSectionOffset(Die, dwarf::DW_AT_GNU_ranges_base, 0);
+  }
 
   return NewCU;
 }

Modified: llvm/trunk/test/DebugInfo/X86/fission-cu.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/fission-cu.ll?rev=204672&r1=204671&r2=204672&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/fission-cu.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/fission-cu.ll Mon Mar 24 16:31:35 2014
@@ -56,11 +56,12 @@
 
 ; CHECK: .debug_info contents:
 ; CHECK: DW_TAG_compile_unit
-; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset]   (0x00000000)
-; CHECK: DW_AT_GNU_dwo_name [DW_FORM_strp] ( .debug_str[0x00000000] = "baz.dwo")
-; CHECK: DW_AT_comp_dir [DW_FORM_strp]     ( .debug_str[0x00000008] = "/usr/local/google/home/echristo/tmp")
-; CHECK: DW_AT_GNU_addr_base [DW_FORM_sec_offset]                   (0x00000000)
-; CHECK: DW_AT_GNU_dwo_id [DW_FORM_data8]  (0x1f1f859683d49324)
+; CHECK-NEXT: DW_AT_stmt_list [DW_FORM_sec_offset]   (0x00000000)
+; CHECK-NEXT: DW_AT_GNU_dwo_name [DW_FORM_strp] ( .debug_str[0x00000000] = "baz.dwo")
+; CHECK-NEXT: DW_AT_comp_dir [DW_FORM_strp]     ( .debug_str[0x00000008] = "/usr/local/google/home/echristo/tmp")
+; CHECK-NEXT: DW_AT_GNU_addr_base [DW_FORM_sec_offset]                   (0x00000000)
+; CHECK-NEXT: DW_AT_GNU_ranges_base [DW_FORM_sec_offset]                   (0x00000000)
+; CHECK-NEXT: DW_AT_GNU_dwo_id [DW_FORM_data8]  (0x1f1f859683d49324)
 
 ; Check that the rest of the compile units have information.
 ; CHECK: .debug_info.dwo contents:
@@ -107,6 +108,7 @@
 ; OBJ-NEXT: R_X86_64_32 .debug_str
 ; OBJ-NEXT: R_X86_64_32 .debug_str
 ; OBJ-NEXT: R_X86_64_32 .debug_addr
+; OBJ-NEXT: R_X86_64_32 .debug_ranges
 ; OBJ-NEXT: }
 
 ; HDR-NOT: .debug_aranges





More information about the llvm-commits mailing list