1 ; RUN: llc < %s -mtriple=thumb-linux-androideabi -verify-machineinstrs | FileCheck %s -check-prefix=Thumb-android
2 ; RUN: llc < %s -mtriple=thumb-linux-unknown-gnueabi -verify-machineinstrs | FileCheck %s -check-prefix=Thumb-linux
3 ; RUN: llc < %s -mtriple=thumb-linux-androideabi -filetype=obj
4 ; RUN: llc < %s -mtriple=thumb-linux-unknown-gnueabi -filetype=obj
7 ; Just to prevent the alloca from being optimized away
8 declare void @dummy_use(ptr, i32)
10 define void @test_basic() #0 {
11 %mem = alloca i32, i32 10
12 call void @dummy_use (ptr %mem, i32 10)
15 ; Thumb-android-LABEL: test_basic:
17 ; Thumb-android: push {r4, r5}
18 ; Thumb-android-NEXT: mov r5, sp
19 ; Thumb-android-NEXT: ldr r4, .LCPI0_0
20 ; Thumb-android-NEXT: ldr r4, [r4]
21 ; Thumb-android-NEXT: cmp r4, r5
22 ; Thumb-android-NEXT: bls .LBB0_2
24 ; Thumb-android: mov r4, #48
25 ; Thumb-android-NEXT: mov r5, #0
26 ; Thumb-android-NEXT: push {lr}
27 ; Thumb-android-NEXT: bl __morestack
28 ; Thumb-android-NEXT: pop {r4}
29 ; Thumb-android-NEXT: mov lr, r4
30 ; Thumb-android-NEXT: pop {r4, r5}
31 ; Thumb-android-NEXT: bx lr
33 ; Thumb-android: pop {r4, r5}
35 ; Thumb-android: .p2align 2
36 ; Thumb-android: .LCPI0_0:
37 ; Thumb-android-NEXT: .long __STACK_LIMIT
39 ; Thumb-linux-LABEL: test_basic:
41 ; Thumb-linux: push {r4, r5}
42 ; Thumb-linux-NEXT: mov r5, sp
43 ; Thumb-linux-NEXT: ldr r4, .LCPI0_0
44 ; Thumb-linux-NEXT: ldr r4, [r4]
45 ; Thumb-linux-NEXT: cmp r4, r5
46 ; Thumb-linux-NEXT: bls .LBB0_2
48 ; Thumb-linux: mov r4, #48
49 ; Thumb-linux-NEXT: mov r5, #0
50 ; Thumb-linux-NEXT: push {lr}
51 ; Thumb-linux-NEXT: bl __morestack
52 ; Thumb-linux-NEXT: pop {r4}
53 ; Thumb-linux-NEXT: mov lr, r4
54 ; Thumb-linux-NEXT: pop {r4, r5}
55 ; Thumb-linux-NEXT: bx lr
57 ; Thumb-linux: pop {r4, r5}
61 define i32 @test_nested(ptr nest %closure, i32 %other) #0 {
62 %addend = load i32 , ptr %closure
63 %result = add i32 %other, %addend
64 %mem = alloca i32, i32 10
65 call void @dummy_use (ptr %mem, i32 10)
68 ; Thumb-android-LABEL: test_nested:
70 ; Thumb-android: push {r4, r5}
71 ; Thumb-android-NEXT: mov r5, sp
72 ; Thumb-android-NEXT: ldr r4, .LCPI1_0
73 ; Thumb-android-NEXT: ldr r4, [r4]
74 ; Thumb-android-NEXT: cmp r4, r5
75 ; Thumb-android-NEXT: bls .LBB1_2
77 ; Thumb-android: mov r4, #56
78 ; Thumb-android-NEXT: mov r5, #0
79 ; Thumb-android-NEXT: push {lr}
80 ; Thumb-android-NEXT: bl __morestack
81 ; Thumb-android-NEXT: pop {r4}
82 ; Thumb-android-NEXT: mov lr, r4
83 ; Thumb-android-NEXT: pop {r4, r5}
84 ; Thumb-android-NEXT: bx lr
86 ; Thumb-android: pop {r4, r5}
88 ; Thumb-linux-LABEL: test_nested:
90 ; Thumb-linux: push {r4, r5}
91 ; Thumb-linux-NEXT: mov r5, sp
92 ; Thumb-linux-NEXT: ldr r4, .LCPI1_0
93 ; Thumb-linux-NEXT: ldr r4, [r4]
94 ; Thumb-linux-NEXT: cmp r4, r5
95 ; Thumb-linux-NEXT: bls .LBB1_2
97 ; Thumb-linux: mov r4, #56
98 ; Thumb-linux-NEXT: mov r5, #0
99 ; Thumb-linux-NEXT: push {lr}
100 ; Thumb-linux-NEXT: bl __morestack
101 ; Thumb-linux-NEXT: pop {r4}
102 ; Thumb-linux-NEXT: mov lr, r4
103 ; Thumb-linux-NEXT: pop {r4, r5}
104 ; Thumb-linux-NEXT: bx lr
106 ; Thumb-linux: pop {r4, r5}
110 define void @test_large() #0 {
111 %mem = alloca i32, i32 10000
112 call void @dummy_use (ptr %mem, i32 0)
115 ; Thumb-android-LABEL: test_large:
117 ; Thumb-android: push {r4, r5}
118 ; Thumb-android-NEXT: mov r5, sp
119 ; Thumb-android-NEXT: ldr r4, .LCPI2_2
120 ; Thumb-android-NEXT: sub r5, r5, r4
121 ; Thumb-android-NEXT: ldr r4, .LCPI2_3
122 ; Thumb-android-NEXT: ldr r4, [r4]
123 ; Thumb-android-NEXT: cmp r4, r5
124 ; Thumb-android-NEXT: bls .LBB2_2
126 ; Thumb-android: ldr r4, .LCPI2_2
127 ; Thumb-android-NEXT: mov r5, #0
128 ; Thumb-android-NEXT: push {lr}
129 ; Thumb-android-NEXT: bl __morestack
130 ; Thumb-android-NEXT: pop {r4}
131 ; Thumb-android-NEXT: mov lr, r4
132 ; Thumb-android-NEXT: pop {r4, r5}
133 ; Thumb-android-NEXT: bx lr
135 ; Thumb-android: pop {r4, r5}
137 ; Thumb-android: .LCPI2_2:
138 ; Thumb-android-NEXT: .long 40192
140 ; Thumb-linux-LABEL: test_large:
142 ; Thumb-linux: push {r4, r5}
143 ; Thumb-linux-NEXT: mov r5, sp
144 ; Thumb-linux-NEXT: ldr r4, .LCPI2_2
145 ; Thumb-linux-NEXT: sub r5, r5, r4
146 ; Thumb-linux-NEXT: ldr r4, .LCPI2_3
147 ; Thumb-linux-NEXT: ldr r4, [r4]
148 ; Thumb-linux-NEXT: cmp r4, r5
149 ; Thumb-linux-NEXT: bls .LBB2_2
151 ; Thumb-linux: ldr r4, .LCPI2_2
152 ; Thumb-linux-NEXT: mov r5, #0
153 ; Thumb-linux-NEXT: push {lr}
154 ; Thumb-linux-NEXT: bl __morestack
155 ; Thumb-linux-NEXT: pop {r4}
156 ; Thumb-linux-NEXT: mov lr, r4
157 ; Thumb-linux-NEXT: pop {r4, r5}
158 ; Thumb-linux-NEXT: bx lr
160 ; Thumb-linux: pop {r4, r5}
164 define fastcc void @test_fastcc() #0 {
165 %mem = alloca i32, i32 10
166 call void @dummy_use (ptr %mem, i32 10)
169 ; Thumb-android-LABEL: test_fastcc:
171 ; Thumb-android: push {r4, r5}
172 ; Thumb-android-NEXT: mov r5, sp
173 ; Thumb-android-NEXT: ldr r4, .LCPI3_0
174 ; Thumb-android-NEXT: ldr r4, [r4]
175 ; Thumb-android-NEXT: cmp r4, r5
176 ; Thumb-android-NEXT: bls .LBB3_2
178 ; Thumb-android: mov r4, #48
179 ; Thumb-android-NEXT: mov r5, #0
180 ; Thumb-android-NEXT: push {lr}
181 ; Thumb-android-NEXT: bl __morestack
182 ; Thumb-android-NEXT: pop {r4}
183 ; Thumb-android-NEXT: mov lr, r4
184 ; Thumb-android-NEXT: pop {r4, r5}
185 ; Thumb-android-NEXT: bx lr
187 ; Thumb-android: pop {r4, r5}
189 ; Thumb-linux-LABEL: test_fastcc:
191 ; Thumb-linux: push {r4, r5}
192 ; Thumb-linux-NEXT: mov r5, sp
193 ; Thumb-linux-NEXT: ldr r4, .LCPI3_0
194 ; Thumb-linux-NEXT: ldr r4, [r4]
195 ; Thumb-linux-NEXT: cmp r4, r5
196 ; Thumb-linux-NEXT: bls .LBB3_2
198 ; Thumb-linux: mov r4, #48
199 ; Thumb-linux-NEXT: mov r5, #0
200 ; Thumb-linux-NEXT: push {lr}
201 ; Thumb-linux-NEXT: bl __morestack
202 ; Thumb-linux-NEXT: pop {r4}
203 ; Thumb-linux-NEXT: mov lr, r4
204 ; Thumb-linux-NEXT: pop {r4, r5}
205 ; Thumb-linux-NEXT: bx lr
207 ; Thumb-linux: pop {r4, r5}
211 define fastcc void @test_fastcc_large() #0 {
212 %mem = alloca i32, i32 10000
213 call void @dummy_use (ptr %mem, i32 0)
216 ; Thumb-android-LABEL: test_fastcc_large:
218 ; Thumb-android: push {r4, r5}
219 ; Thumb-android-NEXT: mov r5, sp
220 ; Thumb-android-NEXT: ldr r4, .LCPI4_2
221 ; Thumb-android-NEXT: sub r5, r5, r4
222 ; Thumb-android-NEXT: ldr r4, .LCPI4_3
223 ; Thumb-android-NEXT: ldr r4, [r4]
224 ; Thumb-android-NEXT: cmp r4, r5
225 ; Thumb-android-NEXT: bls .LBB4_2
227 ; Thumb-android: ldr r4, .LCPI4_2
228 ; Thumb-android-NEXT: mov r5, #0
229 ; Thumb-android-NEXT: push {lr}
230 ; Thumb-android-NEXT: bl __morestack
231 ; Thumb-android-NEXT: pop {r4}
232 ; Thumb-android-NEXT: mov lr, r4
233 ; Thumb-android-NEXT: pop {r4, r5}
234 ; Thumb-android-NEXT: bx lr
236 ; Thumb-android: pop {r4, r5}
238 ; Thumb-android: .LCPI4_2:
239 ; Thumb-android-NEXT: .long 40192
241 ; Thumb-linux-LABEL: test_fastcc_large:
243 ; Thumb-linux: push {r4, r5}
244 ; Thumb-linux-NEXT: mov r5, sp
245 ; Thumb-linux-NEXT: ldr r4, .LCPI4_2
246 ; Thumb-linux-NEXT: sub r5, r5, r4
247 ; Thumb-linux-NEXT: ldr r4, .LCPI4_3
248 ; Thumb-linux-NEXT: ldr r4, [r4]
249 ; Thumb-linux-NEXT: cmp r4, r5
250 ; Thumb-linux-NEXT: bls .LBB4_2
252 ; Thumb-linux: ldr r4, .LCPI4_2
253 ; Thumb-linux-NEXT: mov r5, #0
254 ; Thumb-linux-NEXT: push {lr}
255 ; Thumb-linux-NEXT: bl __morestack
256 ; Thumb-linux-NEXT: pop {r4}
257 ; Thumb-linux-NEXT: mov lr, r4
258 ; Thumb-linux-NEXT: pop {r4, r5}
259 ; Thumb-linux-NEXT: bx lr
261 ; Thumb-linux: pop {r4, r5}
263 ; Thumb-linux: .LCPI4_2:
264 ; Thumb-linux-NEXT: .long 40192
268 define void @test_nostack() #0 {
271 ; Thumb-android-LABEL: test_nostack:
272 ; Thumb-android-NOT: bl __morestack
274 ; Thumb-linux-LABEL: test_nostack:
275 ; Thumb-linux-NOT: bl __morestack
279 declare void @panic() unnamed_addr
281 ; We used to crash while compiling the following function.
282 ; Thumb-linux-LABEL: build_should_not_segfault:
283 ; Thumb-android-LABEL: build_should_not_segfault:
284 define void @build_should_not_segfault(i8 %x) unnamed_addr #0 {
286 %_0 = icmp ult i8 %x, 16
287 %or.cond = select i1 undef, i1 true, i1 %_0
288 br i1 %or.cond, label %bb1, label %bb2
298 attributes #0 = { "split-stack" }