Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / compact-unwind-lsda-folding.s
blobcdabe1b1fe685a8b9a899bf0023e551628950291
1 ## Verify that the compact unwind entries for two functions with identical
2 ## unwind information and LSDA aren't folded together; see the comment in
3 ## UnwindInfoSectionImpl::finalize for why.
5 # REQUIRES: x86
6 # RUN: rm -rf %t; mkdir %t
7 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos11.0 -emit-compact-unwind-non-canonical=true -o %t/lsda.o %s
8 # RUN: %lld -dylib --icf=all -lSystem -lc++ -o %t/liblsda.dylib %t/lsda.o
9 # RUN: llvm-objdump --macho --syms --unwind-info %t/liblsda.dylib | FileCheck %s
11 ## Check that f and g have the same unwind encoding and LSDA offset (we need to
12 ## link with ICF above in order to get the LSDA deduplicated), and that their
13 ## compact unwind entries aren't folded.
15 # CHECK-LABEL: SYMBOL TABLE:
16 # CHECK: [[#%x,G_ADDR:]] {{.*}} __Z1gv
17 # CHECK: [[#%x,H_ADDR:]] {{.*}} __Z1hv
19 # CHECK-LABEL: Contents of __unwind_info section:
20 # CHECK: LSDA descriptors
21 # CHECK-NEXT: [0]: function offset=[[#%#.8x,G_ADDR]], LSDA offset=[[#%#x,LSDA:]]
22 # CHECK-NEXT: [1]: function offset=[[#%#.8x,H_ADDR]], LSDA offset=[[#%#.8x,LSDA]]
23 # CHECK-NEXT: Second level indices:
24 # CHECK: [1]: function offset=[[#%#.8x,G_ADDR]], encoding[0]=[[#%#x,ENCODING:]]
25 # CHECK: [2]: function offset=[[#%#.8x,H_ADDR]], encoding[0]=[[#%#.8x,ENCODING]]
27 ## Generated from the following C++ code built with:
28 ## clang -target x86_64-apple-macosx11.0 -S -Os -fno-inline -fomit-frame-pointer
29 ## void f(int i) { throw i; }
30 ## void g() { try { f(1); } catch (int) {} }
31 ## void h() { try { f(2); } catch (int) {} }
33 .section __TEXT,__text,regular,pure_instructions
34 .globl __Z1fi ## -- Begin function _Z1fi
35 __Z1fi: ## @_Z1fi
36 .cfi_startproc
37 pushq %rbx
38 .cfi_def_cfa_offset 16
39 .cfi_offset %rbx, -16
40 movl %edi, %ebx
41 movl $4, %edi
42 callq ___cxa_allocate_exception
43 movl %ebx, (%rax)
44 movq __ZTIi@GOTPCREL(%rip), %rsi
45 movq %rax, %rdi
46 xorl %edx, %edx
47 callq ___cxa_throw
48 .cfi_endproc
49 ## -- End function
50 .globl __Z1gv ## -- Begin function _Z1gv
51 __Z1gv: ## @_Z1gv
52 Lfunc_begin0:
53 .cfi_startproc
54 .cfi_personality 155, ___gxx_personality_v0
55 .cfi_lsda 16, Lexception0
56 pushq %rax
57 .cfi_def_cfa_offset 16
58 Ltmp0:
59 movl $1, %edi
60 callq __Z1fi
61 Ltmp1:
62 ud2
63 LBB1_2: ## %lpad
64 Ltmp2:
65 movq %rax, %rdi
66 callq ___cxa_begin_catch
67 popq %rax
68 jmp ___cxa_end_catch ## TAILCALL
69 Lfunc_end0:
70 .cfi_endproc
71 .section __TEXT,__gcc_except_tab
72 .p2align 2, 0x0
73 GCC_except_table1:
74 Lexception0:
75 .byte 255 ## @LPStart Encoding = omit
76 .byte 155 ## @TType Encoding = indirect pcrel sdata4
77 .uleb128 Lttbase0-Lttbaseref0
78 Lttbaseref0:
79 .byte 1 ## Call site Encoding = uleb128
80 .uleb128 Lcst_end0-Lcst_begin0
81 Lcst_begin0:
82 .uleb128 Ltmp0-Lfunc_begin0 ## >> Call Site 1 <<
83 .uleb128 Ltmp1-Ltmp0 ## Call between Ltmp0 and Ltmp1
84 .uleb128 Ltmp2-Lfunc_begin0 ## jumps to Ltmp2
85 .byte 1 ## On action: 1
86 .uleb128 Ltmp1-Lfunc_begin0 ## >> Call Site 2 <<
87 .uleb128 Lfunc_end0-Ltmp1 ## Call between Ltmp1 and Lfunc_end0
88 .byte 0 ## has no landing pad
89 .byte 0 ## On action: cleanup
90 Lcst_end0:
91 .byte 1 ## >> Action Record 1 <<
92 ## Catch TypeInfo 1
93 .byte 0 ## No further actions
94 .p2align 2, 0x0
95 ## >> Catch TypeInfos <<
96 .long __ZTIi@GOTPCREL+4 ## TypeInfo 1
97 Lttbase0:
98 .p2align 2, 0x0
99 ## -- End function
100 .section __TEXT,__text,regular,pure_instructions
101 .globl __Z1hv ## -- Begin function _Z1hv
102 __Z1hv: ## @_Z1hv
103 Lfunc_begin1:
104 .cfi_startproc
105 .cfi_personality 155, ___gxx_personality_v0
106 .cfi_lsda 16, Lexception1
107 pushq %rax
108 .cfi_def_cfa_offset 16
109 Ltmp3:
110 movl $2, %edi
111 callq __Z1fi
112 Ltmp4:
114 LBB2_2: ## %lpad
115 Ltmp5:
116 movq %rax, %rdi
117 callq ___cxa_begin_catch
118 popq %rax
119 jmp ___cxa_end_catch ## TAILCALL
120 Lfunc_end1:
121 .cfi_endproc
122 .section __TEXT,__gcc_except_tab
123 .p2align 2, 0x0
124 GCC_except_table2:
125 Lexception1:
126 .byte 255 ## @LPStart Encoding = omit
127 .byte 155 ## @TType Encoding = indirect pcrel sdata4
128 .uleb128 Lttbase1-Lttbaseref1
129 Lttbaseref1:
130 .byte 1 ## Call site Encoding = uleb128
131 .uleb128 Lcst_end1-Lcst_begin1
132 Lcst_begin1:
133 .uleb128 Ltmp3-Lfunc_begin1 ## >> Call Site 1 <<
134 .uleb128 Ltmp4-Ltmp3 ## Call between Ltmp3 and Ltmp4
135 .uleb128 Ltmp5-Lfunc_begin1 ## jumps to Ltmp5
136 .byte 1 ## On action: 1
137 .uleb128 Ltmp4-Lfunc_begin1 ## >> Call Site 2 <<
138 .uleb128 Lfunc_end1-Ltmp4 ## Call between Ltmp4 and Lfunc_end1
139 .byte 0 ## has no landing pad
140 .byte 0 ## On action: cleanup
141 Lcst_end1:
142 .byte 1 ## >> Action Record 1 <<
143 ## Catch TypeInfo 1
144 .byte 0 ## No further actions
145 .p2align 2, 0x0
146 ## >> Catch TypeInfos <<
147 .long __ZTIi@GOTPCREL+4 ## TypeInfo 1
148 Lttbase1:
149 .p2align 2, 0x0
150 ## -- End function
151 .subsections_via_symbols