Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / MC / AArch64 / seh-large-func.s
blobd9defe6b18743a5248e4a7dd7157292d6bb5d7d9
1 // This test checks that we emit unwind info correctly for functions
2 // larger than 1MB.
3 // RUN: llvm-mc -triple aarch64-pc-win32 -filetype=obj %s -o %t.o
4 // RUN: llvm-readobj -S -r -u %t.o | FileCheck %s
6 // CHECK: Section {
7 // CHECK: Number: 4
8 // CHECK-NEXT: Name: .xdata (2E 78 64 61 74 61 00 00)
9 // CHECK-NEXT: VirtualSize: 0x0
10 // CHECK-NEXT: VirtualAddress: 0x0
11 // CHECK-NEXT: RawDataSize: 52
12 // CHECK-NEXT: PointerToRawData: 0x3D0A20
13 // CHECK-NEXT: PointerToRelocations: 0x0
14 // CHECK-NEXT: PointerToLineNumbers: 0x0
15 // CHECK-NEXT: RelocationCount: 0
16 // CHECK-NEXT: LineNumberCount: 0
17 // CHECK-NEXT: Characteristics [ (0x40300040)
18 // CHECK-NEXT: IMAGE_SCN_ALIGN_4BYTES (0x300000)
19 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
20 // CHECK-NEXT: IMAGE_SCN_MEM_READ (0x40000000)
21 // CHECK-NEXT: ]
22 // CHECK-NEXT: }
23 // CHECK-NEXT: Section {
24 // CHECK-NEXT: Number: 5
25 // CHECK-NEXT: Name: .pdata (2E 70 64 61 74 61 00 00)
26 // CHECK-NEXT: VirtualSize: 0x0
27 // CHECK-NEXT: VirtualAddress: 0x0
28 // CHECK-NEXT: RawDataSize: 40
29 // CHECK-NEXT: PointerToRawData: 0x3D0A54
30 // CHECK-NEXT: PointerToRelocations: 0x3D0A7C
31 // CHECK-NEXT: PointerToLineNumbers: 0x0
32 // CHECK-NEXT: RelocationCount: 10
33 // CHECK-NEXT: LineNumberCount: 0
34 // CHECK-NEXT: Characteristics [ (0x40300040)
35 // CHECK-NEXT: IMAGE_SCN_ALIGN_4BYTES (0x300000)
36 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
37 // CHECK-NEXT: IMAGE_SCN_MEM_READ (0x40000000)
38 // CHECK-NEXT: ]
39 // CHECK-NEXT: }
40 // CHECK-NEXT: ]
41 // CHECK-LABEL: Relocations [
42 // CHECK-NEXT: Section (1) .text {
43 // CHECK-NEXT: 0x186A04 IMAGE_REL_ARM64_BRANCH26 foo (14)
44 // CHECK-NEXT: 0x3D091C IMAGE_REL_ARM64_BRANCH26 foo (14)
45 // CHECK-NEXT: }
46 // CHECK-NEXT: Section (5) .pdata {
47 // CHECK-NEXT: 0x0 IMAGE_REL_ARM64_ADDR32NB .text (0)
48 // CHECK-NEXT: 0x4 IMAGE_REL_ARM64_ADDR32NB .xdata (9)
49 // CHECK-NEXT: 0x8 IMAGE_REL_ARM64_ADDR32NB .text (0)
50 // CHECK-NEXT: 0xC IMAGE_REL_ARM64_ADDR32NB .xdata (9)
51 // CHECK-NEXT: 0x10 IMAGE_REL_ARM64_ADDR32NB $L.text_1 (2)
52 // CHECK-NEXT: 0x14 IMAGE_REL_ARM64_ADDR32NB .xdata (9)
53 // CHECK-NEXT: 0x18 IMAGE_REL_ARM64_ADDR32NB $L.text_2 (3)
54 // CHECK-NEXT: 0x1C IMAGE_REL_ARM64_ADDR32NB .xdata (9)
55 // CHECK-NEXT: 0x20 IMAGE_REL_ARM64_ADDR32NB $L.text_3 (4)
56 // CHECK-NEXT: 0x24 IMAGE_REL_ARM64_ADDR32NB .xdata (9)
57 // CHECK-NEXT: }
58 // CHECK-NEXT: ]
59 // CHECK-LABEL: UnwindInformation [
60 // CHECK-NEXT: RuntimeFunction {
61 // CHECK-NEXT: Function: a (0x0)
62 // CHECK-NEXT: ExceptionRecord: .xdata (0x0)
63 // CHECK-NEXT: ExceptionData {
64 // CHECK-NEXT: FunctionLength: 1048572
65 // CHECK-NEXT: Version: 0
66 // CHECK-NEXT: ExceptionData: No
67 // CHECK-NEXT: EpiloguePacked: No
68 // CHECK-NEXT: EpilogueScopes: 0
69 // CHECK-NEXT: ByteCodeLength: 4
70 // CHECK-NEXT: Prologue [
71 // CHECK-NEXT: 0xd561 ; str x30, [sp, #-16]!
72 // CHECK-NEXT: 0xe4 ; end
73 // CHECK-NEXT: ]
74 // CHECK-NEXT: EpilogueScopes [
75 // CHECK-NEXT: ]
76 // CHECK-NEXT: }
77 // CHECK-NEXT: }
78 // CHECK-NEXT: RuntimeFunction {
79 // CHECK-NEXT: Function: a +0xFFFFC (0xFFFFC)
80 // CHECK-NEXT: ExceptionRecord: .xdata +0x8 (0x8)
81 // CHECK-NEXT: ExceptionData {
82 // CHECK-NEXT: FunctionLength: 551444
83 // CHECK-NEXT: Version: 0
84 // CHECK-NEXT: ExceptionData: No
85 // CHECK-NEXT: EpiloguePacked: Yes
86 // CHECK-NEXT: EpilogueOffset: 1
87 // CHECK-NEXT: ByteCodeLength: 4
88 // CHECK-NEXT: Prologue [
89 // CHECK-NEXT: 0xe5 ; end_c
90 // CHECK-NEXT: 0xd561 ; str x30, [sp, #-16]!
91 // CHECK-NEXT: 0xe4 ; end
92 // CHECK-NEXT: ]
93 // CHECK-NEXT: Epilogue [
94 // CHECK-NEXT: 0xd561 ; ldr x30, [sp], #16
95 // CHECK-NEXT: 0xe4 ; end
96 // CHECK-NEXT: ]
97 // CHECK-NEXT: }
98 // CHECK-NEXT: }
99 // CHECK-NEXT: RuntimeFunction {
100 // CHECK-NEXT: Function: b (0x186A10)
101 // CHECK-NEXT: ExceptionRecord: .xdata +0x10 (0x10)
102 // CHECK-NEXT: ExceptionData {
103 // CHECK-NEXT: FunctionLength: 1048572
104 // CHECK-NEXT: Version: 0
105 // CHECK-NEXT: ExceptionData: No
106 // CHECK-NEXT: EpiloguePacked: No
107 // CHECK-NEXT: EpilogueScopes: 0
108 // CHECK-NEXT: ByteCodeLength: 8
109 // CHECK-NEXT: Prologue [
110 // CHECK-NEXT: 0xe1 ; mov fp, sp
111 // CHECK-NEXT: 0xc81e ; stp x19, x20, [sp, #240]
112 // CHECK-NEXT: 0x9f ; stp x29, x30, [sp, #-256]!
113 // CHECK-NEXT: 0xe4 ; end
114 // CHECK-NEXT: ]
115 // CHECK-NEXT: EpilogueScopes [
116 // CHECK-NEXT: ]
117 // CHECK-NEXT: }
118 // CHECK-NEXT: }
119 // CHECK-NEXT: RuntimeFunction {
120 // CHECK-NEXT: Function: $L.text_2 +0x86A0C (0x286A0C)
121 // CHECK-NEXT: ExceptionRecord: .xdata +0x1C (0x1C)
122 // CHECK-NEXT: ExceptionData {
123 // CHECK-NEXT: FunctionLength: 1048572
124 // CHECK-NEXT: Version: 0
125 // CHECK-NEXT: ExceptionData: No
126 // CHECK-NEXT: EpiloguePacked: Yes
127 // CHECK-NEXT: EpilogueOffset: 0
128 // CHECK-NEXT: ByteCodeLength: 8
129 // CHECK-NEXT: Prologue [
130 // CHECK-NEXT: 0xe5 ; end_c
131 // CHECK-NEXT: 0xe1 ; mov fp, sp
132 // CHECK-NEXT: 0xc81e ; stp x19, x20, [sp, #240]
133 // CHECK-NEXT: 0x9f ; stp x29, x30, [sp, #-256]!
134 // CHECK-NEXT: 0xe4 ; end
135 // CHECK-NEXT: ]
136 // CHECK-NEXT: }
137 // CHECK-NEXT: }
138 // CHECK-NEXT: RuntimeFunction {
139 // CHECK-NEXT: Function: $L.text_3 +0x86A08 (0x386A08)
140 // CHECK-NEXT: ExceptionRecord: .xdata +0x28 (0x28)
141 // CHECK-NEXT: ExceptionData {
142 // CHECK-NEXT: FunctionLength: 302888
143 // CHECK-NEXT: Version: 0
144 // CHECK-NEXT: ExceptionData: No
145 // CHECK-NEXT: EpiloguePacked: Yes
146 // CHECK-NEXT: EpilogueOffset: 1
147 // CHECK-NEXT: ByteCodeLength: 8
148 // CHECK-NEXT: Prologue [
149 // CHECK-NEXT: 0xe5 ; end_c
150 // CHECK-NEXT: 0xe1 ; mov fp, sp
151 // CHECK-NEXT: 0xc81e ; stp x19, x20, [sp, #240]
152 // CHECK-NEXT: 0x9f ; stp x29, x30, [sp, #-256]!
153 // CHECK-NEXT: 0xe4 ; end
154 // CHECK-NEXT: ]
155 // CHECK-NEXT: Epilogue [
156 // CHECK-NEXT: 0xe1 ; mov sp, fp
157 // CHECK-NEXT: 0xc81e ; ldp x19, x20, [sp, #240]
158 // CHECK-NEXT: 0x9f ; ldp x29, x30, [sp], #256
159 // CHECK-NEXT: 0xe4 ; end
160 // CHECK-NEXT: ]
161 // CHECK-NEXT: }
162 // CHECK-NEXT: }
163 // CHECK-NEXT: ]
165 .text
166 // A simple function with an single epilog mirroring the prolog.
167 .global a
168 .p2align 2
169 .seh_proc a
171 str x30, [sp, #-16]!
172 .seh_save_reg_x x30, 16
173 .seh_endprologue
174 .rept 400000
176 .endr
177 bl foo
178 .seh_startepilogue
179 ldr x30, [sp], #16
180 .seh_save_reg_x x30, 16
181 .seh_endepilogue
183 .seh_endfunclet
184 .seh_endproc
186 // Example 1 from https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling#function-fragments
187 .global b
188 .p2align 2
189 .seh_proc b
191 stp x29, lr, [sp, #-256]!
192 .seh_save_fplr_x 256
193 stp x19, x20, [sp, #240]
194 .seh_save_regp x19, 240
195 mov x29, fp
196 .seh_set_fp
197 .seh_endprologue
198 .rept 600000
200 .endr
201 bl foo
202 .seh_startepilogue
203 mov sp, x29
204 .seh_set_fp
205 ldp x19, x20, [sp, #240]
206 .seh_save_regp x19, 240
207 ldp x29, lr, [sp], #256
208 .seh_save_fplr_x 256
209 .seh_endepilogue
211 .seh_endfunclet
212 .seh_endproc