Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / gdb-index-dwarf5-type-unit.s
blob5cd6778fe7e4878efeb287d73d8f251d5c911d27
1 # REQUIRES: x86, zlib
2 ## -gdwarf-5 -fdebug-types-section may produce multiple .debug_info sections.
3 ## All except one are type units. Test we can locate the compile unit, add it to
4 ## the index, and not erroneously duplicate it (which would happen if we
5 ## consider every .debug_info a compile unit).
7 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
8 # RUN: ld.lld --gdb-index -Ttext=0x1000 %t.o -o %t
9 # RUN: llvm-dwarfdump --gdb-index %t | FileCheck %s
11 ## Test we don't uncompress a section while another thread is concurrently
12 ## accessing it. This would be detected by tsan as a data race.
13 # RUN: llvm-objcopy --compress-debug-sections %t.o
14 # RUN: ld.lld --gdb-index -Ttext=0x1000 %t.o -o %t1
15 # RUN: llvm-dwarfdump --gdb-index %t1 | FileCheck %s
17 ## In this test, there are actually two compile unit .debug_info (very uncommon;
18 ## -r --unique). Currently we only handle the last compile unit.
19 # CHECK: CU list offset = 0x18, has 1 entries:
20 # CHECK-NEXT: 0: Offset = 0x32, Length = 0x19
22 # CHECK: Address area offset = 0x28, has 1 entries:
23 # CHECK-NEXT: Low/High address = [0x1001, 0x1002) (Size: 0x1), CU id = 0
25 .Lfunc_begin0:
26 ret
27 .Lfunc_end0:
28 .Lfunc_begin1:
29 ret
30 .Lfunc_end1:
32 .section .debug_abbrev,"",@progbits
33 .byte 1 # Abbreviation Code
34 .byte 65 # DW_TAG_type_unit
35 .byte 0 # DW_CHILDREN_no
36 .byte 0 # EOM(1)
37 .byte 0 # EOM(2)
39 .byte 2 # Abbreviation Code
40 .byte 17 # DW_TAG_compile_unit
41 .byte 0 # DW_CHILDREN_no
42 .byte 17 # DW_AT_low_pc
43 .byte 1 # DW_FORM_addr
44 .byte 18 # DW_AT_high_pc
45 .byte 6 # DW_FORM_data4
46 .byte 0 # EOM(1)
47 .byte 0 # EOM(2)
49 .byte 0 # EOM(3)
51 .macro TYPE_UNIT id signature
52 .section .debug_info,"G",@progbits,\signature
53 .long .Ldebug_info_end\id-.Ldebug_info_start\id # Length of Unit
54 .Ldebug_info_start\id:
55 .short 5 # DWARF version number
56 .byte 2 # DWARF Unit Type
57 .byte 8 # Address Size
58 .long .debug_abbrev # Offset Into Abbrev. Section
59 .quad \signature # Type Signature
60 .long .Ldebug_info_end\id # Type DIE Offset
61 .byte 1 # Abbrev [1] DW_TAG_type_unit
62 .Ldebug_info_end\id:
63 .endm
65 ## We place compile units between two type units (rare). A naive approach will
66 ## take either the first or the last .debug_info
67 TYPE_UNIT 0, 123
69 .section .debug_info,"",@progbits,unique,0
70 .Lcu_begin0:
71 .long .Lcu_end0-.Lcu_begin0-4 # Length of Unit
72 .short 5 # DWARF version number
73 .byte 1 # DWARF Unit Type
74 .byte 8 # Address Size
75 .long .debug_abbrev # Offset Into Abbrev. Section
76 .byte 2 # Abbrev [2] DW_TAG_compile_unit
77 .quad .Lfunc_begin0 # DW_AT_low_pc
78 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
79 .Lcu_end0:
81 .section .debug_info,"",@progbits,unique,1
82 .Lcu_begin1:
83 .long .Lcu_end1-.Lcu_begin1-4 # Length of Unit
84 .short 5 # DWARF version number
85 .byte 1 # DWARF Unit Type
86 .byte 8 # Address Size
87 .long .debug_abbrev # Offset Into Abbrev. Section
88 .byte 2 # Abbrev [2] DW_TAG_compile_unit
89 .quad .Lfunc_begin1 # DW_AT_low_pc
90 .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc
91 .Lcu_end1:
93 TYPE_UNIT 1, 456