1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc < %s -mtriple=thumbv6m-none-eabi -frame-pointer=none -verify-machineinstrs | FileCheck %s --check-prefix=FP-NONE
3 ; RUN: llc < %s -mtriple=thumbv6m-none-eabi -frame-pointer=all -verify-machineinstrs | FileCheck %s --check-prefix=FP-ALL
4 ; RUN: llc < %s -mtriple=thumbv6m-none-eabi -frame-pointer=all -mattr=+aapcs-frame-chain -verify-machineinstrs | FileCheck %s --check-prefix=FP-AAPCS
6 define void @ra_call() {
7 ; FP-NONE-LABEL: ra_call:
8 ; FP-NONE: @ %bb.0: @ %entry
9 ; FP-NONE-NEXT: .save {r7, lr}
10 ; FP-NONE-NEXT: push {r7, lr}
11 ; FP-NONE-NEXT: mov r0, lr
12 ; FP-NONE-NEXT: bl sink_ptr
13 ; FP-NONE-NEXT: pop {r7, pc}
15 ; FP-ALL-LABEL: ra_call:
16 ; FP-ALL: @ %bb.0: @ %entry
17 ; FP-ALL-NEXT: .save {r7, lr}
18 ; FP-ALL-NEXT: push {r7, lr}
19 ; FP-ALL-NEXT: .setfp r7, sp
20 ; FP-ALL-NEXT: add r7, sp, #0
21 ; FP-ALL-NEXT: mov r0, lr
22 ; FP-ALL-NEXT: bl sink_ptr
23 ; FP-ALL-NEXT: pop {r7, pc}
25 ; FP-AAPCS-LABEL: ra_call:
26 ; FP-AAPCS: @ %bb.0: @ %entry
27 ; FP-AAPCS-NEXT: .save {lr}
28 ; FP-AAPCS-NEXT: push {lr}
29 ; FP-AAPCS-NEXT: mov r3, r11
30 ; FP-AAPCS-NEXT: .save {r11}
31 ; FP-AAPCS-NEXT: push {r3}
32 ; FP-AAPCS-NEXT: .setfp r11, sp
33 ; FP-AAPCS-NEXT: mov r11, sp
34 ; FP-AAPCS-NEXT: mov r0, lr
35 ; FP-AAPCS-NEXT: bl sink_ptr
36 ; FP-AAPCS-NEXT: pop {r0}
37 ; FP-AAPCS-NEXT: mov r11, r0
38 ; FP-AAPCS-NEXT: pop {pc}
40 %r = tail call ptr @llvm.returnaddress(i32 0)
41 tail call void @sink_ptr(ptr %r)
45 define ptr @ra_return() {
46 ; FP-NONE-LABEL: ra_return:
47 ; FP-NONE: @ %bb.0: @ %entry
48 ; FP-NONE-NEXT: mov r0, lr
51 ; FP-ALL-LABEL: ra_return:
52 ; FP-ALL: @ %bb.0: @ %entry
53 ; FP-ALL-NEXT: .save {r7, lr}
54 ; FP-ALL-NEXT: push {r7, lr}
55 ; FP-ALL-NEXT: .setfp r7, sp
56 ; FP-ALL-NEXT: add r7, sp, #0
57 ; FP-ALL-NEXT: mov r0, lr
58 ; FP-ALL-NEXT: pop {r7, pc}
60 ; FP-AAPCS-LABEL: ra_return:
61 ; FP-AAPCS: @ %bb.0: @ %entry
62 ; FP-AAPCS-NEXT: .save {lr}
63 ; FP-AAPCS-NEXT: push {lr}
64 ; FP-AAPCS-NEXT: mov r3, r11
65 ; FP-AAPCS-NEXT: .save {r11}
66 ; FP-AAPCS-NEXT: push {r3}
67 ; FP-AAPCS-NEXT: .setfp r11, sp
68 ; FP-AAPCS-NEXT: mov r11, sp
69 ; FP-AAPCS-NEXT: mov r0, lr
70 ; FP-AAPCS-NEXT: pop {r1}
71 ; FP-AAPCS-NEXT: mov r11, r1
72 ; FP-AAPCS-NEXT: pop {pc}
74 %r = tail call ptr @llvm.returnaddress(i32 0)
78 define ptr @callee_saved_low() {
79 ; FP-NONE-LABEL: callee_saved_low:
80 ; FP-NONE: @ %bb.0: @ %entry
81 ; FP-NONE-NEXT: .save {r4, r5, r7, lr}
82 ; FP-NONE-NEXT: push {r4, r5, r7, lr}
83 ; FP-NONE-NEXT: mov r0, lr
85 ; FP-NONE-NEXT: @NO_APP
86 ; FP-NONE-NEXT: pop {r4, r5, r7, pc}
88 ; FP-ALL-LABEL: callee_saved_low:
89 ; FP-ALL: @ %bb.0: @ %entry
90 ; FP-ALL-NEXT: .save {r4, r5, r7, lr}
91 ; FP-ALL-NEXT: push {r4, r5, r7, lr}
92 ; FP-ALL-NEXT: .setfp r7, sp, #8
93 ; FP-ALL-NEXT: add r7, sp, #8
94 ; FP-ALL-NEXT: mov r0, lr
96 ; FP-ALL-NEXT: @NO_APP
97 ; FP-ALL-NEXT: pop {r4, r5, r7, pc}
99 ; FP-AAPCS-LABEL: callee_saved_low:
100 ; FP-AAPCS: @ %bb.0: @ %entry
101 ; FP-AAPCS-NEXT: .save {lr}
102 ; FP-AAPCS-NEXT: push {lr}
103 ; FP-AAPCS-NEXT: mov r3, r11
104 ; FP-AAPCS-NEXT: .save {r11}
105 ; FP-AAPCS-NEXT: push {r3}
106 ; FP-AAPCS-NEXT: .setfp r11, sp
107 ; FP-AAPCS-NEXT: mov r11, sp
108 ; FP-AAPCS-NEXT: .save {r4, r5}
109 ; FP-AAPCS-NEXT: push {r4, r5}
110 ; FP-AAPCS-NEXT: mov r0, lr
111 ; FP-AAPCS-NEXT: @APP
112 ; FP-AAPCS-NEXT: @NO_APP
113 ; FP-AAPCS-NEXT: pop {r4, r5}
114 ; FP-AAPCS-NEXT: pop {r1}
115 ; FP-AAPCS-NEXT: mov r11, r1
116 ; FP-AAPCS-NEXT: pop {pc}
118 call void asm sideeffect "", "~{r4},~{r5}"()
119 %r = tail call ptr @llvm.returnaddress(i32 0)
123 define ptr @callee_saved_high() {
124 ; FP-NONE-LABEL: callee_saved_high:
125 ; FP-NONE: @ %bb.0: @ %entry
126 ; FP-NONE-NEXT: mov r3, r9
127 ; FP-NONE-NEXT: mov r2, r8
128 ; FP-NONE-NEXT: .save {r8, r9}
129 ; FP-NONE-NEXT: push {r2, r3}
130 ; FP-NONE-NEXT: mov r0, lr
132 ; FP-NONE-NEXT: @NO_APP
133 ; FP-NONE-NEXT: pop {r1, r2}
134 ; FP-NONE-NEXT: mov r8, r1
135 ; FP-NONE-NEXT: mov r9, r2
136 ; FP-NONE-NEXT: bx lr
138 ; FP-ALL-LABEL: callee_saved_high:
139 ; FP-ALL: @ %bb.0: @ %entry
140 ; FP-ALL-NEXT: .save {r7, lr}
141 ; FP-ALL-NEXT: push {r7, lr}
142 ; FP-ALL-NEXT: .setfp r7, sp
143 ; FP-ALL-NEXT: add r7, sp, #0
144 ; FP-ALL-NEXT: mov r3, r9
145 ; FP-ALL-NEXT: mov r2, r8
146 ; FP-ALL-NEXT: .save {r8, r9}
147 ; FP-ALL-NEXT: push {r2, r3}
148 ; FP-ALL-NEXT: mov r0, lr
150 ; FP-ALL-NEXT: @NO_APP
151 ; FP-ALL-NEXT: pop {r1, r2}
152 ; FP-ALL-NEXT: mov r8, r1
153 ; FP-ALL-NEXT: mov r9, r2
154 ; FP-ALL-NEXT: pop {r7, pc}
156 ; FP-AAPCS-LABEL: callee_saved_high:
157 ; FP-AAPCS: @ %bb.0: @ %entry
158 ; FP-AAPCS-NEXT: .save {lr}
159 ; FP-AAPCS-NEXT: push {lr}
160 ; FP-AAPCS-NEXT: mov r3, r11
161 ; FP-AAPCS-NEXT: .save {r11}
162 ; FP-AAPCS-NEXT: push {r3}
163 ; FP-AAPCS-NEXT: .setfp r11, sp
164 ; FP-AAPCS-NEXT: mov r11, sp
165 ; FP-AAPCS-NEXT: mov r3, r9
166 ; FP-AAPCS-NEXT: mov r2, r8
167 ; FP-AAPCS-NEXT: .save {r8, r9}
168 ; FP-AAPCS-NEXT: push {r2, r3}
169 ; FP-AAPCS-NEXT: mov r0, lr
170 ; FP-AAPCS-NEXT: @APP
171 ; FP-AAPCS-NEXT: @NO_APP
172 ; FP-AAPCS-NEXT: pop {r1, r2}
173 ; FP-AAPCS-NEXT: mov r8, r1
174 ; FP-AAPCS-NEXT: mov r9, r2
175 ; FP-AAPCS-NEXT: pop {r1}
176 ; FP-AAPCS-NEXT: mov r11, r1
177 ; FP-AAPCS-NEXT: pop {pc}
179 call void asm sideeffect "", "~{r8},~{r9}"()
180 %r = tail call ptr @llvm.returnaddress(i32 0)
184 define ptr @large_alloca() {
185 ; FP-NONE-LABEL: large_alloca:
186 ; FP-NONE: @ %bb.0: @ %entry
187 ; FP-NONE-NEXT: .save {r4, r5, r6, lr}
188 ; FP-NONE-NEXT: push {r4, r5, r6, lr}
189 ; FP-NONE-NEXT: ldr r6, .LCPI4_0
190 ; FP-NONE-NEXT: .pad #2000
191 ; FP-NONE-NEXT: add sp, r6
192 ; FP-NONE-NEXT: mov r4, lr
193 ; FP-NONE-NEXT: mov r0, sp
194 ; FP-NONE-NEXT: bl sink_ptr
195 ; FP-NONE-NEXT: mov r0, r4
196 ; FP-NONE-NEXT: ldr r6, .LCPI4_1
197 ; FP-NONE-NEXT: add sp, r6
198 ; FP-NONE-NEXT: pop {r4, r5, r6, pc}
199 ; FP-NONE-NEXT: .p2align 2
200 ; FP-NONE-NEXT: @ %bb.1:
201 ; FP-NONE-NEXT: .LCPI4_0:
202 ; FP-NONE-NEXT: .long 4294965296 @ 0xfffff830
203 ; FP-NONE-NEXT: .LCPI4_1:
204 ; FP-NONE-NEXT: .long 2000 @ 0x7d0
206 ; FP-ALL-LABEL: large_alloca:
207 ; FP-ALL: @ %bb.0: @ %entry
208 ; FP-ALL-NEXT: .save {r4, r6, r7, lr}
209 ; FP-ALL-NEXT: push {r4, r6, r7, lr}
210 ; FP-ALL-NEXT: .setfp r7, sp, #8
211 ; FP-ALL-NEXT: add r7, sp, #8
212 ; FP-ALL-NEXT: ldr r6, .LCPI4_0
213 ; FP-ALL-NEXT: .pad #2000
214 ; FP-ALL-NEXT: add sp, r6
215 ; FP-ALL-NEXT: mov r4, lr
216 ; FP-ALL-NEXT: mov r0, sp
217 ; FP-ALL-NEXT: bl sink_ptr
218 ; FP-ALL-NEXT: mov r0, r4
219 ; FP-ALL-NEXT: subs r6, r7, #7
220 ; FP-ALL-NEXT: subs r6, #1
221 ; FP-ALL-NEXT: mov sp, r6
222 ; FP-ALL-NEXT: pop {r4, r6, r7, pc}
223 ; FP-ALL-NEXT: .p2align 2
224 ; FP-ALL-NEXT: @ %bb.1:
225 ; FP-ALL-NEXT: .LCPI4_0:
226 ; FP-ALL-NEXT: .long 4294965296 @ 0xfffff830
228 ; FP-AAPCS-LABEL: large_alloca:
229 ; FP-AAPCS: @ %bb.0: @ %entry
230 ; FP-AAPCS-NEXT: .save {lr}
231 ; FP-AAPCS-NEXT: push {lr}
232 ; FP-AAPCS-NEXT: mov r3, r11
233 ; FP-AAPCS-NEXT: .save {r11}
234 ; FP-AAPCS-NEXT: push {r3}
235 ; FP-AAPCS-NEXT: .setfp r11, sp
236 ; FP-AAPCS-NEXT: mov r11, sp
237 ; FP-AAPCS-NEXT: .save {r4, r7}
238 ; FP-AAPCS-NEXT: push {r4, r7}
239 ; FP-AAPCS-NEXT: ldr r7, .LCPI4_0
240 ; FP-AAPCS-NEXT: .pad #2000
241 ; FP-AAPCS-NEXT: add sp, r7
242 ; FP-AAPCS-NEXT: mov r4, lr
243 ; FP-AAPCS-NEXT: mov r0, sp
244 ; FP-AAPCS-NEXT: bl sink_ptr
245 ; FP-AAPCS-NEXT: mov r0, r4
246 ; FP-AAPCS-NEXT: mov r7, r11
247 ; FP-AAPCS-NEXT: subs r7, #8
248 ; FP-AAPCS-NEXT: mov sp, r7
249 ; FP-AAPCS-NEXT: pop {r4, r7}
250 ; FP-AAPCS-NEXT: pop {r1}
251 ; FP-AAPCS-NEXT: mov r11, r1
252 ; FP-AAPCS-NEXT: pop {pc}
253 ; FP-AAPCS-NEXT: .p2align 2
254 ; FP-AAPCS-NEXT: @ %bb.1:
255 ; FP-AAPCS-NEXT: .LCPI4_0:
256 ; FP-AAPCS-NEXT: .long 4294965296 @ 0xfffff830
258 %big = alloca i8, i32 2000
259 tail call void @sink_ptr(ptr %big)
260 %r = tail call ptr @llvm.returnaddress(i32 0)
264 define ptr @var_alloca(i32 %size) {
265 ; FP-NONE-LABEL: var_alloca:
266 ; FP-NONE: @ %bb.0: @ %entry
267 ; FP-NONE-NEXT: .save {r4, r6, r7, lr}
268 ; FP-NONE-NEXT: push {r4, r6, r7, lr}
269 ; FP-NONE-NEXT: .setfp r7, sp, #8
270 ; FP-NONE-NEXT: add r7, sp, #8
271 ; FP-NONE-NEXT: mov r6, sp
272 ; FP-NONE-NEXT: mov r4, lr
273 ; FP-NONE-NEXT: adds r0, r0, #7
274 ; FP-NONE-NEXT: movs r1, #7
275 ; FP-NONE-NEXT: bics r0, r1
276 ; FP-NONE-NEXT: mov r1, sp
277 ; FP-NONE-NEXT: subs r0, r1, r0
278 ; FP-NONE-NEXT: mov sp, r0
279 ; FP-NONE-NEXT: bl sink_ptr
280 ; FP-NONE-NEXT: mov r0, r4
281 ; FP-NONE-NEXT: subs r6, r7, #7
282 ; FP-NONE-NEXT: subs r6, #1
283 ; FP-NONE-NEXT: mov sp, r6
284 ; FP-NONE-NEXT: pop {r4, r6, r7, pc}
286 ; FP-ALL-LABEL: var_alloca:
287 ; FP-ALL: @ %bb.0: @ %entry
288 ; FP-ALL-NEXT: .save {r4, r6, r7, lr}
289 ; FP-ALL-NEXT: push {r4, r6, r7, lr}
290 ; FP-ALL-NEXT: .setfp r7, sp, #8
291 ; FP-ALL-NEXT: add r7, sp, #8
292 ; FP-ALL-NEXT: mov r6, sp
293 ; FP-ALL-NEXT: mov r4, lr
294 ; FP-ALL-NEXT: adds r0, r0, #7
295 ; FP-ALL-NEXT: movs r1, #7
296 ; FP-ALL-NEXT: bics r0, r1
297 ; FP-ALL-NEXT: mov r1, sp
298 ; FP-ALL-NEXT: subs r0, r1, r0
299 ; FP-ALL-NEXT: mov sp, r0
300 ; FP-ALL-NEXT: bl sink_ptr
301 ; FP-ALL-NEXT: mov r0, r4
302 ; FP-ALL-NEXT: subs r6, r7, #7
303 ; FP-ALL-NEXT: subs r6, #1
304 ; FP-ALL-NEXT: mov sp, r6
305 ; FP-ALL-NEXT: pop {r4, r6, r7, pc}
307 ; FP-AAPCS-LABEL: var_alloca:
308 ; FP-AAPCS: @ %bb.0: @ %entry
309 ; FP-AAPCS-NEXT: .save {lr}
310 ; FP-AAPCS-NEXT: push {lr}
311 ; FP-AAPCS-NEXT: mov r3, r11
312 ; FP-AAPCS-NEXT: .save {r11}
313 ; FP-AAPCS-NEXT: push {r3}
314 ; FP-AAPCS-NEXT: .setfp r11, sp
315 ; FP-AAPCS-NEXT: mov r11, sp
316 ; FP-AAPCS-NEXT: .save {r4, r6}
317 ; FP-AAPCS-NEXT: push {r4, r6}
318 ; FP-AAPCS-NEXT: mov r6, sp
319 ; FP-AAPCS-NEXT: mov r4, lr
320 ; FP-AAPCS-NEXT: adds r0, r0, #7
321 ; FP-AAPCS-NEXT: movs r1, #7
322 ; FP-AAPCS-NEXT: bics r0, r1
323 ; FP-AAPCS-NEXT: mov r1, sp
324 ; FP-AAPCS-NEXT: subs r0, r1, r0
325 ; FP-AAPCS-NEXT: mov sp, r0
326 ; FP-AAPCS-NEXT: bl sink_ptr
327 ; FP-AAPCS-NEXT: mov r0, r4
328 ; FP-AAPCS-NEXT: mov r6, r11
329 ; FP-AAPCS-NEXT: subs r6, #8
330 ; FP-AAPCS-NEXT: mov sp, r6
331 ; FP-AAPCS-NEXT: pop {r4, r6}
332 ; FP-AAPCS-NEXT: pop {r1}
333 ; FP-AAPCS-NEXT: mov r11, r1
334 ; FP-AAPCS-NEXT: pop {pc}
336 %var = alloca i8, i32 %size
337 tail call void @sink_ptr(ptr %var)
338 %r = tail call ptr @llvm.returnaddress(i32 0)
342 define i32 @all_arg_regs(i32 %a, i32 %b, i32 %c, i32 %d) {
343 ; FP-NONE-LABEL: all_arg_regs:
344 ; FP-NONE: @ %bb.0: @ %entry
345 ; FP-NONE-NEXT: .save {r4, lr}
346 ; FP-NONE-NEXT: push {r4, lr}
347 ; FP-NONE-NEXT: mov r4, lr
348 ; FP-NONE-NEXT: adds r0, r0, r1
349 ; FP-NONE-NEXT: adds r0, r0, r2
350 ; FP-NONE-NEXT: adds r0, r0, r3
351 ; FP-NONE-NEXT: adds r0, r0, r4
352 ; FP-NONE-NEXT: pop {r4, pc}
354 ; FP-ALL-LABEL: all_arg_regs:
355 ; FP-ALL: @ %bb.0: @ %entry
356 ; FP-ALL-NEXT: .save {r4, r6, r7, lr}
357 ; FP-ALL-NEXT: push {r4, r6, r7, lr}
358 ; FP-ALL-NEXT: .setfp r7, sp, #8
359 ; FP-ALL-NEXT: add r7, sp, #8
360 ; FP-ALL-NEXT: mov r4, lr
361 ; FP-ALL-NEXT: adds r0, r0, r1
362 ; FP-ALL-NEXT: adds r0, r0, r2
363 ; FP-ALL-NEXT: adds r0, r0, r3
364 ; FP-ALL-NEXT: adds r0, r0, r4
365 ; FP-ALL-NEXT: pop {r4, r6, r7, pc}
367 ; FP-AAPCS-LABEL: all_arg_regs:
368 ; FP-AAPCS: @ %bb.0: @ %entry
369 ; FP-AAPCS-NEXT: .save {lr}
370 ; FP-AAPCS-NEXT: push {lr}
371 ; FP-AAPCS-NEXT: mov lr, r11
372 ; FP-AAPCS-NEXT: .save {r11}
373 ; FP-AAPCS-NEXT: push {lr}
374 ; FP-AAPCS-NEXT: .setfp r11, sp
375 ; FP-AAPCS-NEXT: mov r11, sp
376 ; FP-AAPCS-NEXT: .save {r4, r7}
377 ; FP-AAPCS-NEXT: push {r4, r7}
378 ; FP-AAPCS-NEXT: ldr r7, [sp, #12]
379 ; FP-AAPCS-NEXT: mov lr, r7
380 ; FP-AAPCS-NEXT: mov r4, lr
381 ; FP-AAPCS-NEXT: adds r0, r0, r1
382 ; FP-AAPCS-NEXT: adds r0, r0, r2
383 ; FP-AAPCS-NEXT: adds r0, r0, r3
384 ; FP-AAPCS-NEXT: adds r0, r0, r4
385 ; FP-AAPCS-NEXT: pop {r4, r7}
386 ; FP-AAPCS-NEXT: pop {r1}
387 ; FP-AAPCS-NEXT: mov r11, r1
388 ; FP-AAPCS-NEXT: pop {pc}
390 %r = tail call ptr @llvm.returnaddress(i32 0)
391 %ri = ptrtoint ptr %r to i32
393 %t2 = add i32 %t1, %c
394 %t3 = add i32 %t2, %d
395 %t4 = add i32 %t3, %ri
399 define ptr @ra_depth_1() {
400 ; FP-NONE-LABEL: ra_depth_1:
401 ; FP-NONE: @ %bb.0: @ %entry
402 ; FP-NONE-NEXT: .save {r7, lr}
403 ; FP-NONE-NEXT: push {r7, lr}
404 ; FP-NONE-NEXT: .setfp r7, sp
405 ; FP-NONE-NEXT: add r7, sp, #0
406 ; FP-NONE-NEXT: ldr r0, [r7]
407 ; FP-NONE-NEXT: ldr r0, [r0, #4]
408 ; FP-NONE-NEXT: pop {r7, pc}
410 ; FP-ALL-LABEL: ra_depth_1:
411 ; FP-ALL: @ %bb.0: @ %entry
412 ; FP-ALL-NEXT: .save {r7, lr}
413 ; FP-ALL-NEXT: push {r7, lr}
414 ; FP-ALL-NEXT: .setfp r7, sp
415 ; FP-ALL-NEXT: add r7, sp, #0
416 ; FP-ALL-NEXT: ldr r0, [r7]
417 ; FP-ALL-NEXT: ldr r0, [r0, #4]
418 ; FP-ALL-NEXT: pop {r7, pc}
420 ; FP-AAPCS-LABEL: ra_depth_1:
421 ; FP-AAPCS: @ %bb.0: @ %entry
422 ; FP-AAPCS-NEXT: .save {lr}
423 ; FP-AAPCS-NEXT: push {lr}
424 ; FP-AAPCS-NEXT: mov r3, r11
425 ; FP-AAPCS-NEXT: .save {r11}
426 ; FP-AAPCS-NEXT: push {r3}
427 ; FP-AAPCS-NEXT: .setfp r11, sp
428 ; FP-AAPCS-NEXT: mov r11, sp
429 ; FP-AAPCS-NEXT: mov r0, r11
430 ; FP-AAPCS-NEXT: ldr r0, [r0]
431 ; FP-AAPCS-NEXT: ldr r0, [r0, #4]
432 ; FP-AAPCS-NEXT: pop {r1}
433 ; FP-AAPCS-NEXT: mov r11, r1
434 ; FP-AAPCS-NEXT: pop {pc}
436 %r = tail call ptr @llvm.returnaddress(i32 1)
440 declare void @sink_ptr(ptr)