1 ; RUN: llc < %s -mtriple=arm-linux-androideabi -mattr=+v4t -verify-machineinstrs | FileCheck %s -check-prefix=ARM-android
2 ; RUN: llc < %s -mtriple=arm-linux-unknown-gnueabi -mattr=+v4t -verify-machineinstrs | FileCheck %s -check-prefix=ARM-linux
4 ; We used to crash with filetype=obj
5 ; RUN: llc < %s -mtriple=arm-linux-androideabi -filetype=obj
6 ; RUN: llc < %s -mtriple=arm-linux-unknown-gnueabi -filetype=obj
9 ; Just to prevent the alloca from being optimized away
10 declare void @dummy_use(i32*, i32)
12 define void @test_basic() #0 {
13 %mem = alloca i32, i32 10
14 call void @dummy_use (i32* %mem, i32 10)
17 ; ARM-linux: test_basic:
19 ; ARM-linux: push {r4, r5}
20 ; ARM-linux-NEXT: mrc p15, #0, r4, c13, c0, #3
21 ; ARM-linux-NEXT: mov r5, sp
22 ; ARM-linux-NEXT: ldr r4, [r4, #4]
23 ; ARM-linux-NEXT: cmp r4, r5
24 ; ARM-linux-NEXT: blo .LBB0_2
26 ; ARM-linux: mov r4, #48
27 ; ARM-linux-NEXT: mov r5, #0
28 ; ARM-linux-NEXT: stmdb sp!, {lr}
29 ; ARM-linux-NEXT: bl __morestack
30 ; ARM-linux-NEXT: ldm sp!, {lr}
31 ; ARM-linux-NEXT: pop {r4, r5}
32 ; ARM-linux-NEXT: bx lr
34 ; ARM-linux: pop {r4, r5}
36 ; ARM-android: test_basic:
38 ; ARM-android: push {r4, r5}
39 ; ARM-android-NEXT: mrc p15, #0, r4, c13, c0, #3
40 ; ARM-android-NEXT: mov r5, sp
41 ; ARM-android-NEXT: ldr r4, [r4, #252]
42 ; ARM-android-NEXT: cmp r4, r5
43 ; ARM-android-NEXT: blo .LBB0_2
45 ; ARM-android: mov r4, #48
46 ; ARM-android-NEXT: mov r5, #0
47 ; ARM-android-NEXT: stmdb sp!, {lr}
48 ; ARM-android-NEXT: bl __morestack
49 ; ARM-android-NEXT: ldm sp!, {lr}
50 ; ARM-android-NEXT: pop {r4, r5}
51 ; ARM-android-NEXT: bx lr
53 ; ARM-android: pop {r4, r5}
57 define i32 @test_nested(i32 * nest %closure, i32 %other) #0 {
58 %addend = load i32 , i32 * %closure
59 %result = add i32 %other, %addend
60 %mem = alloca i32, i32 10
61 call void @dummy_use (i32* %mem, i32 10)
64 ; ARM-linux: test_nested:
66 ; ARM-linux: push {r4, r5}
67 ; ARM-linux-NEXT: mrc p15, #0, r4, c13, c0, #3
68 ; ARM-linux-NEXT: mov r5, sp
69 ; ARM-linux-NEXT: ldr r4, [r4, #4]
70 ; ARM-linux-NEXT: cmp r4, r5
71 ; ARM-linux-NEXT: blo .LBB1_2
73 ; ARM-linux: mov r4, #56
74 ; ARM-linux-NEXT: mov r5, #0
75 ; ARM-linux-NEXT: stmdb sp!, {lr}
76 ; ARM-linux-NEXT: bl __morestack
77 ; ARM-linux-NEXT: ldm sp!, {lr}
78 ; ARM-linux-NEXT: pop {r4, r5}
79 ; ARM-linux-NEXT: bx lr
81 ; ARM-linux: pop {r4, r5}
83 ; ARM-android: test_nested:
85 ; ARM-android: push {r4, r5}
86 ; ARM-android-NEXT: mrc p15, #0, r4, c13, c0, #3
87 ; ARM-android-NEXT: mov r5, sp
88 ; ARM-android-NEXT: ldr r4, [r4, #252]
89 ; ARM-android-NEXT: cmp r4, r5
90 ; ARM-android-NEXT: blo .LBB1_2
92 ; ARM-android: mov r4, #56
93 ; ARM-android-NEXT: mov r5, #0
94 ; ARM-android-NEXT: stmdb sp!, {lr}
95 ; ARM-android-NEXT: bl __morestack
96 ; ARM-android-NEXT: ldm sp!, {lr}
97 ; ARM-android-NEXT: pop {r4, r5}
98 ; ARM-android-NEXT: bx lr
100 ; ARM-android: pop {r4, r5}
104 define void @test_large() #0 {
105 %mem = alloca i32, i32 10000
106 call void @dummy_use (i32* %mem, i32 0)
109 ; ARM-linux: test_large:
111 ; ARM-linux: push {r4, r5}
112 ; ARM-linux-NEXT: mrc p15, #0, r4, c13, c0, #3
113 ; ARM-linux-NEXT: sub r5, sp, #40192
114 ; ARM-linux-NEXT: ldr r4, [r4, #4]
115 ; ARM-linux-NEXT: cmp r4, r5
116 ; ARM-linux-NEXT: blo .LBB2_2
118 ; ARM-linux: mov r4, #40192
119 ; ARM-linux-NEXT: mov r5, #0
120 ; ARM-linux-NEXT: stmdb sp!, {lr}
121 ; ARM-linux-NEXT: bl __morestack
122 ; ARM-linux-NEXT: ldm sp!, {lr}
123 ; ARM-linux-NEXT: pop {r4, r5}
124 ; ARM-linux-NEXT: bx lr
126 ; ARM-linux: pop {r4, r5}
128 ; ARM-android: test_large:
130 ; ARM-android: push {r4, r5}
131 ; ARM-android-NEXT: mrc p15, #0, r4, c13, c0, #3
132 ; ARM-android-NEXT: sub r5, sp, #40192
133 ; ARM-android-NEXT: ldr r4, [r4, #252]
134 ; ARM-android-NEXT: cmp r4, r5
135 ; ARM-android-NEXT: blo .LBB2_2
137 ; ARM-android: mov r4, #40192
138 ; ARM-android-NEXT: mov r5, #0
139 ; ARM-android-NEXT: stmdb sp!, {lr}
140 ; ARM-android-NEXT: bl __morestack
141 ; ARM-android-NEXT: ldm sp!, {lr}
142 ; ARM-android-NEXT: pop {r4, r5}
143 ; ARM-android-NEXT: bx lr
145 ; ARM-android: pop {r4, r5}
149 define fastcc void @test_fastcc() #0 {
150 %mem = alloca i32, i32 10
151 call void @dummy_use (i32* %mem, i32 10)
154 ; ARM-linux: test_fastcc:
156 ; ARM-linux: push {r4, r5}
157 ; ARM-linux-NEXT: mrc p15, #0, r4, c13, c0, #3
158 ; ARM-linux-NEXT: mov r5, sp
159 ; ARM-linux-NEXT: ldr r4, [r4, #4]
160 ; ARM-linux-NEXT: cmp r4, r5
161 ; ARM-linux-NEXT: blo .LBB3_2
163 ; ARM-linux: mov r4, #48
164 ; ARM-linux-NEXT: mov r5, #0
165 ; ARM-linux-NEXT: stmdb sp!, {lr}
166 ; ARM-linux-NEXT: bl __morestack
167 ; ARM-linux-NEXT: ldm sp!, {lr}
168 ; ARM-linux-NEXT: pop {r4, r5}
169 ; ARM-linux-NEXT: bx lr
171 ; ARM-linux: pop {r4, r5}
173 ; ARM-android: test_fastcc:
175 ; ARM-android: push {r4, r5}
176 ; ARM-android-NEXT: mrc p15, #0, r4, c13, c0, #3
177 ; ARM-android-NEXT: mov r5, sp
178 ; ARM-android-NEXT: ldr r4, [r4, #252]
179 ; ARM-android-NEXT: cmp r4, r5
180 ; ARM-android-NEXT: blo .LBB3_2
182 ; ARM-android: mov r4, #48
183 ; ARM-android-NEXT: mov r5, #0
184 ; ARM-android-NEXT: stmdb sp!, {lr}
185 ; ARM-android-NEXT: bl __morestack
186 ; ARM-android-NEXT: ldm sp!, {lr}
187 ; ARM-android-NEXT: pop {r4, r5}
188 ; ARM-android-NEXT: bx lr
190 ; ARM-android: pop {r4, r5}
194 define fastcc void @test_fastcc_large() #0 {
195 %mem = alloca i32, i32 10000
196 call void @dummy_use (i32* %mem, i32 0)
199 ; ARM-linux: test_fastcc_large:
201 ; ARM-linux: push {r4, r5}
202 ; ARM-linux-NEXT: mrc p15, #0, r4, c13, c0, #3
203 ; ARM-linux-NEXT: sub r5, sp, #40192
204 ; ARM-linux-NEXT: ldr r4, [r4, #4]
205 ; ARM-linux-NEXT: cmp r4, r5
206 ; ARM-linux-NEXT: blo .LBB4_2
208 ; ARM-linux: mov r4, #40192
209 ; ARM-linux-NEXT: mov r5, #0
210 ; ARM-linux-NEXT: stmdb sp!, {lr}
211 ; ARM-linux-NEXT: bl __morestack
212 ; ARM-linux-NEXT: ldm sp!, {lr}
213 ; ARM-linux-NEXT: pop {r4, r5}
214 ; ARM-linux-NEXT: bx lr
216 ; ARM-linux: pop {r4, r5}
218 ; ARM-android: test_fastcc_large:
220 ; ARM-android: push {r4, r5}
221 ; ARM-android-NEXT: mrc p15, #0, r4, c13, c0, #3
222 ; ARM-android-NEXT: sub r5, sp, #40192
223 ; ARM-android-NEXT: ldr r4, [r4, #252]
224 ; ARM-android-NEXT: cmp r4, r5
225 ; ARM-android-NEXT: blo .LBB4_2
227 ; ARM-android: mov r4, #40192
228 ; ARM-android-NEXT: mov r5, #0
229 ; ARM-android-NEXT: stmdb sp!, {lr}
230 ; ARM-android-NEXT: bl __morestack
231 ; ARM-android-NEXT: ldm sp!, {lr}
232 ; ARM-android-NEXT: pop {r4, r5}
233 ; ARM-android-NEXT: bx lr
235 ; ARM-android: pop {r4, r5}
239 define void @test_nostack() #0 {
242 ; ARM-linux-LABEL: test_nostack:
243 ; ARM-linux-NOT: bl __morestack
245 ; ARM-android-LABEL: test_nostack:
246 ; ARM-android-NOT: bl __morestack
249 ; Test to make sure that a morestack call is generated if there is a
250 ; sibling call, even if the function in question has no stack frame
253 declare i32 @callee(i32)
255 define i32 @test_sibling_call_empty_frame(i32 %x) #0 {
256 %call = tail call i32 @callee(i32 %x) #0
259 ; ARM-linux: test_sibling_call_empty_frame:
260 ; ARM-linux: bl __morestack
262 ; ARM-android: test_sibling_call_empty_frame:
263 ; ARM-android: bl __morestack
267 attributes #0 = { "split-stack" }