Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / MC / AArch64 / seh.s
blob4faf7daaa33eddcb172ce9713069aeb8b6cfec7d
1 // This test checks that the SEH directives emit the correct unwind data.
3 // RUN: llvm-mc -triple aarch64-pc-win32 -filetype=obj %s | llvm-readobj -S -r -u - | FileCheck %s
5 // Check that the output assembler directives also can be parsed, and
6 // that they produce equivalent output:
8 // RUN: llvm-mc -triple aarch64-pc-win32 -filetype=asm %s | llvm-mc -triple aarch64-pc-win32 -filetype=obj - | llvm-readobj -S -r -u - | FileCheck %s
10 // CHECK: Sections [
11 // CHECK: Section {
12 // CHECK: Name: .text
13 // CHECK: RelocationCount: 0
14 // CHECK: Characteristics [
15 // CHECK-NEXT: ALIGN_4BYTES
16 // CHECK-NEXT: CNT_CODE
17 // CHECK-NEXT: MEM_EXECUTE
18 // CHECK-NEXT: MEM_READ
19 // CHECK-NEXT: ]
20 // CHECK-NEXT: }
21 // CHECK: Section {
22 // CHECK: Name: .xdata
23 // CHECK: RawDataSize: 92
24 // CHECK: RelocationCount: 1
25 // CHECK: Characteristics [
26 // CHECK-NEXT: ALIGN_4BYTES
27 // CHECK-NEXT: CNT_INITIALIZED_DATA
28 // CHECK-NEXT: MEM_READ
29 // CHECK-NEXT: ]
30 // CHECK-NEXT: }
31 // CHECK: Section {
32 // CHECK: Name: .pdata
33 // CHECK: RelocationCount: 2
34 // CHECK: Characteristics [
35 // CHECK-NEXT: ALIGN_4BYTES
36 // CHECK-NEXT: CNT_INITIALIZED_DATA
37 // CHECK-NEXT: MEM_READ
38 // CHECK-NEXT: ]
39 // CHECK-NEXT: }
40 // CHECK-NEXT: ]
42 // CHECK-NEXT: Relocations [
43 // CHECK-NEXT: Section (4) .xdata {
44 // CHECK-NEXT: 0x50 IMAGE_REL_ARM64_ADDR32NB __C_specific_handler
45 // CHECK-NEXT: }
46 // CHECK-NEXT: Section (5) .pdata {
47 // CHECK-NEXT: 0x0 IMAGE_REL_ARM64_ADDR32NB .text
48 // CHECK-NEXT: 0x4 IMAGE_REL_ARM64_ADDR32NB .xdata
49 // CHECK-NEXT: }
50 // CHECK-NEXT: ]
52 // CHECK-NEXT: UnwindInformation [
53 // CHECK-NEXT: RuntimeFunction {
54 // CHECK-NEXT: Function: func
55 // CHECK-NEXT: ExceptionRecord: .xdata
56 // CHECK-NEXT: ExceptionData {
57 // CHECK-NEXT: FunctionLength: 152
58 // CHECK: Prologue [
59 // CHECK-NEXT: 0xe76983 ; stp q9, q10, [sp, #-64]!
60 // CHECK-NEXT: 0xe73d83 ; str q29, [sp, #-64]!
61 // CHECK-NEXT: 0xe76243 ; stp d2, d3, [sp, #-64]!
62 // CHECK-NEXT: 0xe73f43 ; str d31, [sp, #-64]!
63 // CHECK-NEXT: 0xe77d03 ; stp x29, x30, [sp, #-64]!
64 // CHECK-NEXT: 0xe73e03 ; str x30, [sp, #-64]!
65 // CHECK-NEXT: 0xe74384 ; stp q3, q4, [sp, #64]
66 // CHECK-NEXT: 0xe71e84 ; str q30, [sp, #64]
67 // CHECK-NEXT: 0xe74444 ; stp d4, d5, [sp, #64]
68 // CHECK-NEXT: 0xe71d48 ; str d29, [sp, #64]
69 // CHECK-NEXT: 0xe74104 ; stp x1, x2, [sp, #64]
70 // CHECK-NEXT: 0xe70008 ; str x0, [sp, #64]
71 // CHECK-NEXT: 0xfc ; pacibsp
72 // CHECK-NEXT: 0xec ; clear unwound to call
73 // CHECK-NEXT: 0xea ; context
74 // CHECK-NEXT: 0xe9 ; machine frame
75 // CHECK-NEXT: 0xe8 ; trap frame
76 // CHECK-NEXT: 0xe3 ; nop
77 // CHECK-NEXT: 0xe202 ; add fp, sp, #16
78 // CHECK-NEXT: 0xdd41 ; str d13, [sp, #8]
79 // CHECK-NEXT: 0xde83 ; str d12, [sp, #-32]!
80 // CHECK-NEXT: 0xd884 ; stp d10, d11, [sp, #32]
81 // CHECK-NEXT: 0xda05 ; stp d8, d9, [sp, #-48]!
82 // CHECK-NEXT: 0x83 ; stp x29, x30, [sp, #-32]!
83 // CHECK-NEXT: 0x46 ; stp x29, x30, [sp, #48]
84 // CHECK-NEXT: 0xd141 ; str x24, [sp, #8]
85 // CHECK-NEXT: 0xd483 ; str x23, [sp, #-32]!
86 // CHECK-NEXT: 0xe6 ; save next
87 // CHECK-NEXT: 0xc882 ; stp x21, x22, [sp, #16]
88 // CHECK-NEXT: 0xd6c2 ; stp x25, lr, [sp, #16]
89 // CHECK-NEXT: 0x24 ; stp x19, x20, [sp, #-32]!
90 // CHECK-NEXT: 0xcc83 ; stp x21, x22, [sp, #-32]!
91 // CHECK-NEXT: 0x83 ; stp x29, x30, [sp, #-32]!
92 // CHECK-NEXT: 0xe1 ; mov fp, sp
93 // CHECK-NEXT: 0x01 ; sub sp, #16
94 // CHECK-NEXT: 0xe4 ; end
95 // CHECK-NEXT: ]
96 // CHECK-NEXT: EpilogueScopes [
97 // CHECK-NEXT: EpilogueScope {
98 // CHECK-NEXT: StartOffset: 36
99 // CHECK-NEXT: EpilogueStartIndex: 68
100 // CHECK-NEXT: Opcodes [
101 // CHECK-NEXT: 0x01 ; add sp, #16
102 // CHECK-NEXT: 0xe4 ; end
103 // CHECK-NEXT: ]
104 // CHECK-NEXT: }
105 // CHECK-NEXT: ]
106 // CHECK-NEXT: ExceptionHandler [
107 // CHECK-NEXT: Routine: __C_specific_handler (0x0)
108 // CHECK-NEXT: Parameter: 0x0
109 // CHECK-NEXT: ]
110 // CHECK-NEXT: }
111 // CHECK-NEXT: }
112 // CHECK-NEXT: ]
115 .text
116 .globl func
117 .def func
118 .scl 2
119 .type 32
120 .endef
121 .seh_proc func
122 func:
123 sub sp, sp, #24
124 .seh_stackalloc 24
125 mov x29, sp
126 .seh_set_fp
127 stp x29, x30, [sp, #-32]!
128 .seh_save_fplr_x 32
129 stp x21, x22, [sp, #-32]!
130 .seh_save_regp_x x21, 32
131 stp x19, x20, [sp, #-32]!
132 .seh_save_r19r20_x 32
133 stp x25, x30, [sp, #16]
134 .seh_save_lrpair x25, 16
135 stp x21, x22, [sp, #16]
136 .seh_save_regp x21, 16
137 stp x23, x24, [sp, #32]
138 .seh_save_next
139 str x23, [sp, #-32]!
140 .seh_save_reg_x x23, 32
141 str x24, [sp, #8]
142 .seh_save_reg x24, 8
143 stp x29, x30, [sp, #48]
144 .seh_save_fplr 48
145 stp x29, x30, [sp, #-32]!
146 .seh_save_fplr_x 32
147 stp d8, d9, [sp, #-48]!
148 .seh_save_fregp_x d8, 48
149 stp d10, d11, [sp, #32]
150 .seh_save_fregp d10, 32
151 str d12, [sp, #-32]!
152 .seh_save_freg_x d12, 32
153 str d13, [sp, #8]
154 .seh_save_freg d13, 8
155 add x29, sp, #16
156 .seh_add_fp 16
158 .seh_nop
160 .seh_trap_frame
162 .seh_pushframe
164 .seh_context
166 .seh_clear_unwound_to_call
167 pacibsp
168 .seh_pac_sign_lr
170 .seh_save_any_reg x0, 64
172 .seh_save_any_reg_p x1, 64
174 .seh_save_any_reg d29, 64
176 .seh_save_any_reg_p d4, 64
178 .seh_save_any_reg q30, 64
180 .seh_save_any_reg_p q3, 64
182 .seh_save_any_reg_x lr, 64
184 .seh_save_any_reg_px fp, 64
186 .seh_save_any_reg_x d31, 64
188 .seh_save_any_reg_px d2, 64
190 .seh_save_any_reg_x q29, 64
192 .seh_save_any_reg_px q9, 64
193 .seh_endprologue
195 .seh_startepilogue
196 add sp, sp, #24
197 .seh_stackalloc 24
198 .seh_endepilogue
200 .seh_handler __C_specific_handler, @except
201 .seh_handlerdata
202 .long 0
203 .text
204 .seh_endproc
206 // Function with no .seh directives; no pdata/xdata entries are
207 // generated.
208 .globl smallFunc
209 .def smallFunc
210 .scl 2
211 .type 32
212 .endef
213 .seh_proc smallFunc
214 smallFunc:
216 .seh_endproc
218 // Function with no .seh directives, but with .seh_handlerdata.
219 // No xdata/pdata entries are generated, but the custom handler data
220 // (the .long after .seh_handlerdata) is left orphaned in the xdata
221 // section.
222 .globl handlerFunc
223 .def handlerFunc
224 .scl 2
225 .type 32
226 .endef
227 .seh_proc handlerFunc
228 handlerFunc:
230 .seh_handler __C_specific_handler, @except
231 .seh_handlerdata
232 .long 0
233 .text
234 .seh_endproc