1 ; Disable shrink-wrapping on the first test otherwise we wouldn't
2 ; exerce the path for PR18136.
3 ; RUN: llc -mtriple=thumbv7-apple-none-macho < %s -enable-shrink-wrap=false | FileCheck %s
4 ; RUN: llc -mtriple=thumbv6m-apple-none-macho -frame-pointer=all < %s | FileCheck %s --check-prefix=CHECK-T1
5 ; RUN: llc -mtriple=thumbv7-apple-darwin-ios -frame-pointer=all < %s | FileCheck %s --check-prefix=CHECK-IOS
6 ; RUN: llc -mtriple=thumbv7--linux-gnueabi -frame-pointer=all < %s | FileCheck %s --check-prefix=CHECK-LINUX
11 %bigVec = type [2 x double]
13 @var = global %bigVec zeroinitializer
15 define void @check_simple() minsize {
16 ; CHECK-LABEL: check_simple:
17 ; CHECK: push {r3, r4, r5, r6, r7, lr}
18 ; CHECK-NOT: sub sp, sp,
20 ; CHECK-NOT: add sp, sp,
21 ; CHECK: pop {r0, r1, r2, r3, r7, pc}
23 ; CHECK-T1-LABEL: check_simple:
24 ; CHECK-T1: push {r3, r4, r5, r6, r7, lr}
25 ; CHECK-T1: add r7, sp, #16
26 ; CHECK-T1-NOT: sub sp, sp,
28 ; CHECK-T1-NOT: add sp, sp,
29 ; CHECK-T1: pop {r0, r1, r2, r3, r7, pc}
31 ; iOS always has a frame pointer and messing with the push affects
32 ; how it's set in the prologue. Make sure we get that right.
33 ; CHECK-IOS-LABEL: check_simple:
34 ; CHECK-IOS: push {r3, r4, r5, r6, r7, lr}
36 ; CHECK-IOS: add r7, sp, #16
40 ; CHEC: pop {r3, r4, r5, r6, r7, pc}
42 %var = alloca i8, i32 16
43 call void @bar(i8* %var)
47 define void @check_simple_too_big() minsize {
48 ; CHECK-LABEL: check_simple_too_big:
49 ; CHECK: push {r7, lr}
54 %var = alloca i8, i32 64
55 call void @bar(i8* %var)
59 define void @check_vfp_fold() minsize {
60 ; CHECK-LABEL: check_vfp_fold:
61 ; CHECK: push {r[[GLOBREG:[0-9]+]], lr}
62 ; CHECK: vpush {d6, d7, d8, d9}
66 ; CHECK: vpop {d6, d7, d8, d9}
67 ; CHECK: pop {r[[GLOBREG]], pc}
69 ; iOS uses aligned NEON stores here, which is convenient since we
70 ; want to make sure that works too.
71 ; CHECK-IOS-LABEL: check_vfp_fold:
72 ; CHECK-IOS: push {r4, r7, lr}
73 ; CHECK-IOS: sub.w r4, sp, #16
74 ; CHECK-IOS: bfc r4, #0, #4
75 ; CHECK-IOS: mov sp, r4
76 ; CHECK-IOS: vst1.64 {d8, d9}, [r4:128]
77 ; CHECK-IOS: sub sp, #16
79 ; CHECK-IOS: add r4, sp, #16
80 ; CHECK-IOS: vld1.64 {d8, d9}, [r4:128]
81 ; CHECK-IOS: mov sp, r4
82 ; CHECK-IOS: pop {r4, r7, pc}
84 %var = alloca i8, i32 16
86 call void asm "", "r,~{d8},~{d9}"(i8* %var)
87 call void @bar(i8* %var)
92 ; This function should use just enough space that the "add sp, sp, ..." could be
93 ; folded in except that doing so would clobber the value being returned.
94 define i64 @check_no_return_clobber() minsize {
95 ; CHECK-LABEL: check_no_return_clobber:
96 ; CHECK: push {r1, r2, r3, r4, r5, r6, r7, lr}
100 ; CHECK: pop {r7, pc}
102 ; Just to keep iOS FileCheck within previous function:
103 ; CHECK-IOS-LABEL: check_no_return_clobber:
105 %var = alloca i8, i32 20
106 call void @bar(i8* %var)
110 define arm_aapcs_vfpcc double @check_vfp_no_return_clobber() minsize {
111 ; CHECK-LABEL: check_vfp_no_return_clobber:
112 ; CHECK: push {r[[GLOBREG:[0-9]+]], lr}
113 ; CHECK: vpush {d0, d1, d2, d3, d4, d5, d6, d7, d8, d9}
117 ; CHECK: vpop {d8, d9}
118 ; CHECK: pop {r[[GLOBREG]], pc}
120 %var = alloca i8, i32 64
122 %tmp = load %bigVec, %bigVec* @var
123 call void @bar(i8* %var)
124 store %bigVec %tmp, %bigVec* @var
129 @dbl = global double 0.0
131 ; PR18136: there was a bug determining where the first eligible pop in a
132 ; basic-block was when the entire block was epilogue code.
133 define void @test_fold_point(i1 %tst) minsize {
134 ; CHECK-LABEL: test_fold_point:
136 ; Important to check for beginning of basic block, because if it gets
137 ; if-converted the test is probably no longer checking what it should.
139 ; CHECK-NEXT: vpop {d7, d8}
140 ; CHECK-NEXT: pop {r4, pc}
142 ; With a guaranteed frame-pointer, we want to make sure that its offset in the
143 ; push block is correct, even if a few registers have been tacked onto a later
145 ; CHECK-IOS-LABEL: test_fold_point:
146 ; CHECK-IOS: push {r4, r7, lr}
147 ; CHECK-IOS-NEXT: add r7, sp, #4
148 ; CHECK-IOS-NEXT: vpush {d7, d8}
150 ; We want some memory so there's a stack adjustment to fold...
151 %var = alloca i8, i32 8
153 ; We want a long-lived floating register so that a callee-saved dN is used and
154 ; there's both a vpop and a pop.
155 %live_val = load double, double* @dbl
156 br i1 %tst, label %true, label %end
158 call void @bar(i8* %var)
159 store double %live_val, double* @dbl
162 ; We want the epilogue to be the only thing in a basic block so that we hit
163 ; the correct edge-case (first inst in block is correct one to adjust).
167 define void @test_varsize(...) minsize {
168 ; CHECK-T1-LABEL: test_varsize:
169 ; CHECK-T1: sub sp, #16
170 ; CHECK-T1: push {r5, r6, r7, lr}
172 ; CHECK-T1: pop {r2, r3, r7}
173 ; CHECK-T1: pop {[[POP_REG:r[0-3]]]}
174 ; CHECK-T1: add sp, #16
175 ; CHECK-T1: bx [[POP_REG]]
177 ; CHECK-LABEL: test_varsize:
179 ; CHECK: push {r5, r6, r7, lr}
181 ; CHECK: pop.w {r2, r3, r7, lr}
185 %var = alloca i8, i32 8
186 call void @llvm.va_start(i8* %var)
187 call void @bar(i8* %var)
191 %"MyClass" = type { i8*, i32, i32, float, float, float, [2 x i8], i32, i32* }
197 declare %"MyClass"* @bar2(%"MyClass"* returned, i16*, i32, float, float, i32, i32, i1 zeroext, i1 zeroext, i32)
199 define fastcc float @check_vfp_no_return_clobber2(i16* %r, i16* %chars, i32 %length, i1 zeroext %flag) minsize {
201 ; CHECK-LINUX-LABEL: check_vfp_no_return_clobber2
202 ; CHECK-LINUX: vpush {d0, d1, d2, d3, d4, d5, d6, d7, d8}
205 ; CHECK-LINUX: add sp
206 ; CHECK-LINUX: vpop {d8}
207 %run = alloca %"MyClass", align 4
208 %call = call %"MyClass"* @bar2(%"MyClass"* %run, i16* %chars, i32 %length, float 0.000000e+00, float 0.000000e+00, i32 1, i32 1, i1 zeroext false, i1 zeroext true, i32 3)
209 %call1 = call float @foo()
210 %cmp = icmp eq %"MyClass"* %run, null
211 br i1 %cmp, label %exit, label %if.then
213 if.then: ; preds = %entry
217 exit: ; preds = %if.then, %entry
221 declare void @use_arr(i32*)
222 define void @test_fold_reuse() minsize {
223 ; CHECK-LABEL: test_fold_reuse:
224 ; CHECK: push.w {r4, r7, r8, lr}
228 ; CHECK: pop.w {r4, r7, r8, pc}
229 %arr = alloca i8, i32 24
230 call void asm sideeffect "", "~{r8},~{r4}"()
231 call void @bar(i8* %arr)
235 declare void @llvm.va_start(i8*) nounwind