Turn on CU ranges if we've got multiple compile units in the same
authorEric Christopher <echristo@gmail.com>
Wed, 29 Jan 2014 22:06:27 +0000 (22:06 +0000)
committerEric Christopher <echristo@gmail.com>
Wed, 29 Jan 2014 22:06:27 +0000 (22:06 +0000)
module since there's no range guarantee that we could make given
output order. This also fixes up the testcases that have multiple
CUs to have the correct range offset.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200422 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
test/DebugInfo/X86/stmt-list-multiple-compile-units.ll

index 66be6058fd2edf3024c223b76d2cd23f6aa34df6..d557f403480296bd53cd01929bb522802ec25152 100644 (file)
@@ -1119,10 +1119,12 @@ void DwarfDebug::endSections() {
   }
 
   // For now only turn on CU ranges if we've explicitly asked for it,
-  // we have -ffunction-sections enabled, or we've emitted a function
-  // into a unique section. At this point all sections should be finalized
-  // except for dwarf sections.
-  HasCURanges = DwarfCURanges || UsedNonDefaultText ||
+  // we have -ffunction-sections enabled, we've emitted a function
+  // into a unique section, or we're using LTO. If we're using LTO then
+  // we can't know that any particular function in the module is correlated
+  // to a particular CU and so we need to be conservative. At this point all
+  // sections should be finalized except for dwarf sections.
+  HasCURanges = DwarfCURanges || UsedNonDefaultText || (CUMap.size() > 1) ||
                 TargetMachine::getFunctionSections();
 }
 
index e63cbd11e48faddaaa14384404f7a5b7db37b10d..5cb8f613a340188de3270af66cea26bb69e8f20a 100644 (file)
@@ -8,11 +8,11 @@
 ; CHECK: .debug_info contents:
 ; CHECK: DW_TAG_compile_unit
 ; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset]   (0x00000000)
-; CHECK: DW_AT_low_pc [DW_FORM_addr]       (0x0000000000000000)
+; CHECK: DW_AT_ranges [DW_FORM_sec_offset]      (0x00000000)
 
 ; CHECK: DW_TAG_compile_unit
 ; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset]   (0x0000003c)
-; CHECK: DW_AT_low_pc [DW_FORM_addr]       (0x0000000000000000)
+; CHECK: DW_AT_ranges [DW_FORM_sec_offset]      (0x00000020)
 
 ; CHECK: .debug_line contents:
 ; CHECK-NEXT: Line table prologue:
 
 ; DWARF3: .debug_info contents:
 ; DWARF3: DW_TAG_compile_unit
-; DWARF3: DW_AT_stmt_list [DW_FORM_data4]   (0x00000000)
-; DWARF3: DW_AT_low_pc [DW_FORM_addr]       (0x0000000000000000)
+; DWARF3: DW_AT_stmt_list [DW_FORM_data4]    (0x00000000)
+; DWARF3: DW_AT_ranges [DW_FORM_data4]       (0x00000000)
 
 ; DWARF3: DW_TAG_compile_unit
 ; DWARF3: DW_AT_stmt_list [DW_FORM_data4]   (0x0000003c)
-; DWARF3: DW_AT_low_pc [DW_FORM_addr]       (0x0000000000000000)
+; DWARF3: DW_AT_ranges [DW_FORM_data4]      (0x00000020)
 
 ; DWARF3: .debug_line contents:
 ; DWARF3-NEXT: Line table prologue: