Skip to content

Commit 12bc084

Browse files
authored
[MC][COFF] Add missing sections for DWO (#157239)
Add DWO sections `.debug_loclists.dwo` and `.debug_rnglists.dwo` to the COFF targets. This enables building with `-DLLVM_USE_SPLIT_DWARF=ON` on the Cygwin target, which previously failed due to compiler crashes.
1 parent 6e904e8 commit 12bc084

File tree

5 files changed

+49
-10
lines changed

5 files changed

+49
-10
lines changed

llvm/lib/MC/MCObjectFileInfo.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,18 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
776776
".debug_loc.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
777777
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
778778
COFF::IMAGE_SCN_MEM_READ);
779+
DwarfLoclistsDWOSection = Ctx->getCOFFSection(
780+
".debug_loclists.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
781+
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
782+
COFF::IMAGE_SCN_MEM_READ);
779783
DwarfStrOffDWOSection = Ctx->getCOFFSection(
780784
".debug_str_offsets.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
781785
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
782786
COFF::IMAGE_SCN_MEM_READ);
787+
DwarfRnglistsDWOSection = Ctx->getCOFFSection(
788+
".debug_rnglists.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
789+
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
790+
COFF::IMAGE_SCN_MEM_READ);
783791
DwarfAddrSection = Ctx->getCOFFSection(
784792
".debug_addr", COFF::IMAGE_SCN_MEM_DISCARDABLE |
785793
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |

llvm/test/CodeGen/X86/debug-loclists.ll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | \
33
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF32
44

5+
; RUN: llc -mtriple=x86_64-pc-mingw -filetype=obj -function-sections -o %t -experimental-debug-variable-locations=true < %s
6+
; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | \
7+
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF32
8+
59
; RUN: llc -dwarf64 -mtriple=x86_64-pc-linux -filetype=obj -function-sections -o %t -experimental-debug-variable-locations=true < %s
610
; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | \
711
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF64
@@ -10,27 +14,31 @@
1014
; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | \
1115
; RUN: FileCheck %s --check-prefixes=DWO,DWO32
1216

17+
; RUN: llc -dwarf-version=5 -split-dwarf-file=foo.dwo -mtriple=x86_64-pc-mingw -filetype=obj -function-sections -o %t -experimental-debug-variable-locations=true < %s
18+
; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | \
19+
; RUN: FileCheck %s --check-prefixes=DWO,DWO32
20+
1321
; RUN: llc -dwarf64 -dwarf-version=5 -split-dwarf-file=foo.dwo -mtriple=x86_64-pc-linux -filetype=obj -function-sections -o %t -experimental-debug-variable-locations=true < %s
1422
; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | \
1523
; RUN: FileCheck %s --check-prefixes=DWO,DWO64
1624

1725
; CHECK: DW_TAG_variable
1826
; DWARF32-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x0) loclist = 0x00000018:
1927
; DWARF64-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x0) loclist = 0x0000002c:
20-
; CHECK-NEXT: [0x0000000000000000, 0x0000000000000003) ".text._Z2f1ii": DW_OP_consts +5, DW_OP_stack_value)
28+
; CHECK-NEXT: [0x0000000000000000, 0x0000000000000003) ".text{{[.$]}}_Z2f1ii": DW_OP_consts +5, DW_OP_stack_value)
2129
; CHECK-NEXT: DW_AT_name {{.*}} "x"
2230

2331
; CHECK: DW_TAG_variable
2432
; DWARF32-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x1) loclist = 0x00000020:
2533
; DWARF64-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x1) loclist = 0x00000034:
26-
; CHECK-NEXT: [0x0000000000000000, 0x0000000000000003) ".text._Z2f1ii": DW_OP_consts +3, DW_OP_stack_value
27-
; CHECK-NEXT: [0x0000000000000003, 0x0000000000000004) ".text._Z2f1ii": DW_OP_consts +4, DW_OP_stack_value)
34+
; CHECK-NEXT: [0x0000000000000000, 0x0000000000000003) ".text{{[.$]}}_Z2f1ii": DW_OP_consts +3, DW_OP_stack_value
35+
; CHECK-NEXT: [0x0000000000000003, 0x0000000000000004) ".text{{[.$]}}_Z2f1ii": DW_OP_consts +4, DW_OP_stack_value)
2836
; CHECK-NEXT: DW_AT_name {{.*}} "y"
2937

3038
; CHECK: DW_TAG_variable
3139
; DWARF32-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x2) loclist = 0x00000031:
3240
; DWARF64-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x2) loclist = 0x00000045:
33-
; CHECK-NEXT: [0x0000000000000003, 0x0000000000000004) ".text._Z2f1ii": DW_OP_reg0 RAX)
41+
; CHECK-NEXT: [0x0000000000000003, 0x0000000000000004) ".text{{[.$]}}_Z2f1ii": DW_OP_reg0 RAX)
3442
; CHECK-NEXT: DW_AT_name {{.*}} "r"
3543

3644
; CHECK: .debug_loclists contents:

llvm/test/DebugInfo/X86/convert-loclist.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
; RUN: llc -mtriple=x86_64 -split-dwarf-file=foo.dwo -filetype=asm -dwarf-op-convert=Enable < %s \
66
; RUN: | FileCheck --check-prefix=ASM %s
77

8+
; RUN: llc -mtriple=x86_64-mingw -filetype=obj < %s \
9+
; RUN: | llvm-dwarfdump -debug-info -debug-loclists - | FileCheck %s
10+
; RUN: llc -mtriple=x86_64-mingw -split-dwarf-file=foo.dwo -filetype=obj -dwarf-op-convert=Enable < %s \
11+
; RUN: | llvm-dwarfdump -debug-info -debug-loclists - | FileCheck --check-prefix=SPLIT --check-prefix=CHECK %s
12+
; RUN: llc -mtriple=x86_64-mingw -split-dwarf-file=foo.dwo -filetype=asm -dwarf-op-convert=Enable < %s \
13+
; RUN: | FileCheck --check-prefix=ASM %s
14+
815
; A bit of a brittle test - this is testing the specific DWO_id. The
916
; alternative would be to test two files with different DW_OP_convert values &
1017
; ensuring the DWO IDs differ when the DW_OP_convert parameter differs.

llvm/test/DebugInfo/X86/ranges_always_default.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@
33
; RUN: | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \
44
; RUN: | FileCheck --check-prefix=RANGE %s
55

6+
; RUN: llc -O0 %s -mtriple=x86_64-unknown-win32-gnu -filetype=obj -o - -minimize-addr-in-v5=Default \
7+
; RUN: -split-dwarf-file=test.dwo \
8+
; RUN: | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \
9+
; RUN: | FileCheck --check-prefix=RANGE %s
10+
611
; RUN: llc -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o - -minimize-addr-in-v5=Disabled \
712
; RUN: -split-dwarf-file=test.dwo \
813
; RUN: | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \
914
; RUN: | FileCheck --check-prefix=NORANGE %s
1015

16+
; RUN: llc -O0 %s -mtriple=x86_64-unknown-win32-gnu -filetype=obj -o - -minimize-addr-in-v5=Disabled \
17+
; RUN: -split-dwarf-file=test.dwo \
18+
; RUN: | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \
19+
; RUN: | FileCheck --check-prefix=NORANGE %s
20+
1121
; A simpler example than used in ranges_always.ll, since this doesn't test all
1222
; the nuances of where minimizing ranges are useful. This is only testing the
1323
; defaulting behavior - specifically that the "ranges" version of the

llvm/test/DebugInfo/X86/split-dwarf-v5-ranges.ll

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
; RUN: llc -split-dwarf-file=foo.dwo -mtriple=x86_64-unknown-linux-gnu -filetype=obj %s -o %t32
22
; RUN: llvm-dwarfdump -v -debug-info -debug-rnglists %t32 | \
3-
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF32
3+
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF32,CHECK-ELF
4+
5+
; RUN: llc -split-dwarf-file=foo.dwo -mtriple=x86_64-unknown-win32-gnu -filetype=obj %s -o %t32
6+
; RUN: llvm-dwarfdump -v -debug-info -debug-rnglists %t32 | \
7+
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF32,CHECK-COFF
48

59
; RUN: llc -dwarf64 -split-dwarf-file=foo.dwo -mtriple=x86_64-unknown-linux-gnu -filetype=obj %s -o %t64
610
; RUN: llvm-dwarfdump -v -debug-info -debug-rnglists %t64 | \
7-
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF64
11+
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF64,CHECK-ELF
812

913
; CHECK: .debug_info contents:
1014
; CHECK: .debug_info.dwo contents:
1115
; CHECK: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x[[#%.8x,RNG_OFF:]]
12-
; CHECK: [0x0000000000000001, 0x000000000000000c) ".text"
13-
; CHECK: [0x000000000000000e, 0x0000000000000013) ".text")
16+
; CHECK-ELF: [0x[[#%.16x,BEGIN1:0x01]], 0x[[#%.16x,END1:0x0c]]) ".text"
17+
; CHECK-ELF: [0x[[#%.16x,BEGIN2:0x0e]], 0x[[#%.16x,END2:0x13]]) ".text")
18+
; CHECK-COFF: [0x[[#%.16x,BEGIN1:0x04]], 0x[[#%.16x,END1:0x0f]]) ".text"
19+
; CHECK-COFF: [0x[[#%.16x,BEGIN2:0x11]], 0x[[#%.16x,END2:0x17]]) ".text")
1420

1521
; CHECK: .debug_rnglists.dwo contents:
1622
; DWARF32: 0x00000000: range list header: length = 0x00000015, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000001
@@ -21,8 +27,8 @@
2127
; CHECK: ]
2228
; CHECK: ranges:
2329
; CHECK: 0x[[#RNG_OFF]]: [DW_RLE_base_addressx]: 0x0000000000000000
24-
; CHECK: 0x[[#RNG_OFF+2]]: [DW_RLE_offset_pair ]: 0x0000000000000001, 0x000000000000000c => [0x0000000000000001, 0x000000000000000c)
25-
; CHECK: 0x[[#RNG_OFF+5]]: [DW_RLE_offset_pair ]: 0x000000000000000e, 0x0000000000000013 => [0x000000000000000e, 0x0000000000000013)
30+
; CHECK: 0x[[#RNG_OFF+2]]: [DW_RLE_offset_pair ]: 0x[[#%.16x,BEGIN1]], 0x[[#%.16x,END1]] => [0x[[#%.16x,BEGIN1]], 0x[[#%.16x,END1]])
31+
; CHECK: 0x[[#RNG_OFF+5]]: [DW_RLE_offset_pair ]: 0x[[#%.16x,BEGIN2]], 0x[[#%.16x,END2]] => [0x[[#%.16x,BEGIN2]], 0x[[#%.16x,END2]])
2632
; CHECK: 0x[[#RNG_OFF+8]]: [DW_RLE_end_of_list ]
2733

2834
; Function Attrs: noinline optnone uwtable

0 commit comments

Comments
 (0)