Form reform for MCDwarf.
authorPaul Robinson <paul_robinson@playstation.sony.com>
Wed, 23 Dec 2015 01:57:31 +0000 (01:57 +0000)
committerPaul Robinson <paul_robinson@playstation.sony.com>
Wed, 23 Dec 2015 01:57:31 +0000 (01:57 +0000)
MCDwarf emits a canned abbreviation table, but was not emitting proper
forms for DWARF version 4, which is the default after r249655.

Differential Revision: http://reviews.llvm.org/D15732

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

lib/MC/MCDwarf.cpp
test/MC/ARM/dwarf-asm-multiple-sections-dwarf-2.s
test/MC/ARM/dwarf-asm-multiple-sections.s
test/MC/ARM/dwarf-asm-nonstandard-section.s
test/MC/ARM/dwarf-asm-single-section.s
test/MC/MachO/gen-dwarf.s

index a63feeff857d00e393b61669d0d357a9f8aa16c8..c97d9bb6f92e11867a5a0d33d055dbfdffed8447 100644 (file)
@@ -514,10 +514,14 @@ static void EmitGenDwarfAbbrev(MCStreamer *MCOS) {
   MCOS->EmitULEB128IntValue(1);
   MCOS->EmitULEB128IntValue(dwarf::DW_TAG_compile_unit);
   MCOS->EmitIntValue(dwarf::DW_CHILDREN_yes, 1);
-  EmitAbbrev(MCOS, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4);
-  if (MCOS->getContext().getGenDwarfSectionSyms().size() > 1 &&
-      MCOS->getContext().getDwarfVersion() >= 3) {
-    EmitAbbrev(MCOS, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4);
+  EmitAbbrev(MCOS, dwarf::DW_AT_stmt_list,
+             context.getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
+                                            : dwarf::DW_FORM_data4);
+  if (context.getGenDwarfSectionSyms().size() > 1 &&
+      context.getDwarfVersion() >= 3) {
+    EmitAbbrev(MCOS, dwarf::DW_AT_ranges,
+               context.getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
+                                              : dwarf::DW_FORM_data4);
   } else {
     EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr);
     EmitAbbrev(MCOS, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr);
index 5bf8fbd57fa5b874b520475fd93a0fb55d6695a4..d23c9a93de335f40ff05d655970c15f360003dcd 100644 (file)
@@ -25,7 +25,7 @@ b:
 
 // DWARF: .debug_info contents:
 // DWARF: 0x{{[0-9a-f]+}}: DW_TAG_compile_unit [1]
-// CHECK-NOT-DWARF: DW_TAG_
+// DWARF-NOT: DW_TAG_
 // DWARF:               DW_AT_low_pc [DW_FORM_addr]       (0x0000000000000000)
 // DWARF:               DW_AT_high_pc [DW_FORM_addr]      (0x0000000000000004)
 
index 0eb8bab8162099547a5de49aed17e1a31704c2ea..49550559e9567b50d1f4e441d8819f379721180f 100644 (file)
@@ -1,6 +1,8 @@
 // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -fdebug-compilation-dir=/tmp
-// RUN: llvm-dwarfdump %t | FileCheck -check-prefix DWARF %s
+// RUN: llvm-dwarfdump %t | FileCheck -check-prefix DWARF -check-prefix DWARF4 %s
 // RUN: llvm-objdump -r %t | FileCheck -check-prefix RELOC %s
+// RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 3 -fdebug-compilation-dir=/tmp
+// RUN: llvm-dwarfdump %t | FileCheck -check-prefix DWARF -check-prefix DWARF3 %s
 // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 2 2>&1 | FileCheck -check-prefix VERSION %s
 // RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 1 2>&1 | FileCheck -check-prefix DWARF1 %s
 // RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 5 2>&1 | FileCheck -check-prefix DWARF5 %s
@@ -15,8 +17,10 @@ b:
 // DWARF: .debug_abbrev contents:
 // DWARF: Abbrev table for offset: 0x00000000
 // DWARF: [1] DW_TAG_compile_unit DW_CHILDREN_yes
-// DWARF:         DW_AT_stmt_list DW_FORM_data4
-// DWARF:         DW_AT_ranges    DW_FORM_data4
+// DWARF3:        DW_AT_stmt_list DW_FORM_data4
+// DWARF4:        DW_AT_stmt_list DW_FORM_sec_offset
+// DWARF3:        DW_AT_ranges    DW_FORM_data4
+// DWARF4:        DW_AT_ranges    DW_FORM_sec_offset
 // DWARF:         DW_AT_name      DW_FORM_string
 // DWARF:         DW_AT_comp_dir  DW_FORM_string
 // DWARF:         DW_AT_producer  DW_FORM_string
@@ -24,8 +28,9 @@ b:
 
 // DWARF: .debug_info contents:
 // DWARF: 0x{{[0-9a-f]+}}: DW_TAG_compile_unit [1]
-// CHECK-NOT-DWARF: DW_TAG_
-// DWARF: DW_AT_ranges [DW_FORM_data4]      (0x00000000
+// DWARF-NOT: DW_TAG_
+// DWARF3: DW_AT_ranges [DW_FORM_data4]           (0x00000000
+// DWARF4: DW_AT_ranges [DW_FORM_sec_offset]      (0x00000000
 
 // DWARF: 0x{{[0-9a-f]+}}:   DW_TAG_label [2] *
 // DWARF-NEXT: DW_AT_name [DW_FORM_string]     ("a")
@@ -41,10 +46,10 @@ b:
 
 
 // DWARF: .debug_line contents:
-// DWARF:      0x0000000000000000      9      0      1   0   0  is_stmt
-// DWARF-NEXT: 0x0000000000000004      9      0      1   0   0  is_stmt end_sequence
-// DWARF-NEXT: 0x0000000000000000     13      0      1   0   0  is_stmt
-// DWARF-NEXT: 0x0000000000000004     13      0      1   0   0  is_stmt end_sequence
+// DWARF:      0x0000000000000000     11      0      1   0   0  is_stmt
+// DWARF-NEXT: 0x0000000000000004     11      0      1   0   0  is_stmt end_sequence
+// DWARF-NEXT: 0x0000000000000000     15      0      1   0   0  is_stmt
+// DWARF-NEXT: 0x0000000000000004     15      0      1   0   0  is_stmt end_sequence
 
 
 // DWARF: .debug_ranges contents:
index 497a39ad11626f06f6ff3b67ecf114a552bd12b3..39065a4d05f1e6d29ab8205034973f49b7ee0b07 100644 (file)
@@ -9,7 +9,7 @@ b:
 // DWARF: .debug_abbrev contents:
 // DWARF: Abbrev table for offset: 0x00000000
 // DWARF: [1] DW_TAG_compile_unit DW_CHILDREN_yes
-// DWARF:         DW_AT_stmt_list DW_FORM_data4
+// DWARF:         DW_AT_stmt_list DW_FORM_sec_offset
 // DWARF:         DW_AT_low_pc    DW_FORM_addr
 // DWARF:         DW_AT_high_pc   DW_FORM_addr
 // DWARF:         DW_AT_name      DW_FORM_string
index c57e6498a38a59f6accd066fa8404b5068a1caa9..808236f65b3fc31d653afe1f5526204dd92279e7 100644 (file)
@@ -10,7 +10,7 @@ a:
 // DWARF: .debug_abbrev contents:
 // DWARF: Abbrev table for offset: 0x00000000
 // DWARF: [1] DW_TAG_compile_unit DW_CHILDREN_yes
-// DWARF:         DW_AT_stmt_list DW_FORM_data4
+// DWARF:         DW_AT_stmt_list DW_FORM_sec_offset
 // DWARF:         DW_AT_low_pc    DW_FORM_addr
 // DWARF:         DW_AT_high_pc   DW_FORM_addr
 // DWARF:         DW_AT_name      DW_FORM_string
@@ -20,7 +20,7 @@ a:
 
 // DWARF: .debug_info contents:
 // DWARF: 0x{{[0-9a-f]+}}: DW_TAG_compile_unit [1]
-// CHECK-NOT-DWARF: DW_TAG_
+// DWARF-NOT: DW_TAG_
 // DWARF:               DW_AT_low_pc [DW_FORM_addr]       (0x0000000000000000)
 // DWARF:               DW_AT_high_pc [DW_FORM_addr]      (0x0000000000000004)
 
index ad0a562aaf70d3b706add01e8738b0bebc70a6d9..22a8e93799d69da9ee56b8fccf7713402ecb6547 100644 (file)
@@ -17,7 +17,7 @@ _x:   .long 1
 // CHECK: .debug_abbrev contents:
 // CHECK: Abbrev table for offset: 0x00000000
 // CHECK: [1] DW_TAG_compile_unit      DW_CHILDREN_yes
-// CHECK:      DW_AT_stmt_list DW_FORM_data4
+// CHECK:      DW_AT_stmt_list DW_FORM_sec_offset
 // CHECK:      DW_AT_low_pc    DW_FORM_addr
 // CHECK:      DW_AT_high_pc   DW_FORM_addr
 // CHECK:      DW_AT_name      DW_FORM_string
@@ -39,7 +39,7 @@ _x:   .long 1
 
 // We don't check the leading addresses these are at.
 // CHECK:  DW_TAG_compile_unit [1] *
-// CHECK:    DW_AT_stmt_list [DW_FORM_data4]   (0x00000000)
+// CHECK:    DW_AT_stmt_list [DW_FORM_sec_offset]      (0x00000000)
 // CHECK:    DW_AT_low_pc [DW_FORM_addr]       (0x0000000000000000)
 // CHECK:    DW_AT_high_pc [DW_FORM_addr]      (0x0000000000000008)
 // We don't check the file name as it is a temp directory