1 ; RUN: llc -mtriple thumbv6m-arm-none-eabi -filetype asm -o - %s -frame-pointer=all --verify-machineinstrs | FileCheck %s --check-prefixes=FP,LEAF-FP
2 ; RUN: llc -mtriple thumbv6m-arm-none-eabi -filetype asm -o - %s -frame-pointer=all -mattr=+aapcs-frame-chain --verify-machineinstrs | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-FP-AAPCS
3 ; RUN: llc -mtriple thumbv6m-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf --verify-machineinstrs | FileCheck %s --check-prefixes=FP,LEAF-NOFP
4 ; RUN: llc -mtriple thumbv6m-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf -mattr=+aapcs-frame-chain --verify-machineinstrs | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-NOFP-AAPCS
5 ; RUN: llc -mtriple thumbv6m-arm-none-eabi -filetype asm -o - %s -frame-pointer=none --verify-machineinstrs | FileCheck %s --check-prefixes=NOFP,LEAF-NOFP
6 ; RUN: llc -mtriple thumbv6m-arm-none-eabi -filetype asm -o - %s -frame-pointer=none -mattr=+aapcs-frame-chain --verify-machineinstrs | FileCheck %s --check-prefixes=NOFP-AAPCS,LEAF-NOFP-AAPCS
8 define dso_local noundef i32 @leaf(i32 noundef %0) {
11 ; LEAF-FP-NEXT: .pad #4
12 ; LEAF-FP-NEXT: sub sp, #4
13 ; LEAF-FP-NEXT: str r0, [sp]
14 ; LEAF-FP-NEXT: adds r0, r0, #4
15 ; LEAF-FP-NEXT: add sp, #4
18 ; LEAF-FP-AAPCS-LABEL: leaf:
19 ; LEAF-FP-AAPCS: @ %bb.0:
20 ; LEAF-FP-AAPCS-NEXT: .save {lr}
21 ; LEAF-FP-AAPCS-NEXT: push {lr}
22 ; LEAF-FP-AAPCS-NEXT: mov lr, r11
23 ; LEAF-FP-AAPCS-NEXT: .save {r11}
24 ; LEAF-FP-AAPCS-NEXT: push {lr}
25 ; LEAF-FP-AAPCS-NEXT: .setfp r11, sp
26 ; LEAF-FP-AAPCS-NEXT: mov r11, sp
27 ; LEAF-FP-AAPCS-NEXT: .pad #4
28 ; LEAF-FP-AAPCS-NEXT: sub sp, #4
29 ; LEAF-FP-AAPCS-NEXT: str r0, [sp]
30 ; LEAF-FP-AAPCS-NEXT: adds r0, r0, #4
31 ; LEAF-FP-AAPCS-NEXT: add sp, #4
32 ; LEAF-FP-AAPCS-NEXT: pop {r1}
33 ; LEAF-FP-AAPCS-NEXT: mov r11, r1
34 ; LEAF-FP-AAPCS-NEXT: pop {pc}
36 ; LEAF-NOFP-LABEL: leaf:
38 ; LEAF-NOFP-NEXT: .pad #4
39 ; LEAF-NOFP-NEXT: sub sp, #4
40 ; LEAF-NOFP-NEXT: str r0, [sp]
41 ; LEAF-NOFP-NEXT: adds r0, r0, #4
42 ; LEAF-NOFP-NEXT: add sp, #4
43 ; LEAF-NOFP-NEXT: bx lr
45 ; LEAF-NOFP-AAPCS-LABEL: leaf:
46 ; LEAF-NOFP-AAPCS: @ %bb.0:
47 ; LEAF-NOFP-AAPCS-NEXT: .pad #4
48 ; LEAF-NOFP-AAPCS-NEXT: sub sp, #4
49 ; LEAF-NOFP-AAPCS-NEXT: str r0, [sp]
50 ; LEAF-NOFP-AAPCS-NEXT: adds r0, r0, #4
51 ; LEAF-NOFP-AAPCS-NEXT: add sp, #4
52 ; LEAF-NOFP-AAPCS-NEXT: bx lr
53 %2 = alloca i32, align 4
54 store i32 %0, ptr %2, align 4
55 %3 = load i32, ptr %2, align 4
56 %4 = add nsw i32 %3, 4
60 define dso_local noundef i32 @non_leaf(i32 noundef %0) {
63 ; FP-NEXT: .save {r7, lr}
64 ; FP-NEXT: push {r7, lr}
65 ; FP-NEXT: .setfp r7, sp
66 ; FP-NEXT: add r7, sp, #0
69 ; FP-NEXT: str r0, [sp, #4]
71 ; FP-NEXT: adds r0, r0, #1
73 ; FP-NEXT: pop {r7, pc}
75 ; FP-AAPCS-LABEL: non_leaf:
77 ; FP-AAPCS-NEXT: .save {lr}
78 ; FP-AAPCS-NEXT: push {lr}
79 ; FP-AAPCS-NEXT: mov lr, r11
80 ; FP-AAPCS-NEXT: .save {r11}
81 ; FP-AAPCS-NEXT: push {lr}
82 ; FP-AAPCS-NEXT: .setfp r11, sp
83 ; FP-AAPCS-NEXT: mov r11, sp
84 ; FP-AAPCS-NEXT: .pad #8
85 ; FP-AAPCS-NEXT: sub sp, #8
86 ; FP-AAPCS-NEXT: str r0, [sp, #4]
87 ; FP-AAPCS-NEXT: bl leaf
88 ; FP-AAPCS-NEXT: adds r0, r0, #1
89 ; FP-AAPCS-NEXT: add sp, #8
90 ; FP-AAPCS-NEXT: pop {r1}
91 ; FP-AAPCS-NEXT: mov r11, r1
92 ; FP-AAPCS-NEXT: pop {pc}
94 ; NOFP-LABEL: non_leaf:
96 ; NOFP-NEXT: .save {r7, lr}
97 ; NOFP-NEXT: push {r7, lr}
99 ; NOFP-NEXT: sub sp, #8
100 ; NOFP-NEXT: str r0, [sp, #4]
102 ; NOFP-NEXT: adds r0, r0, #1
103 ; NOFP-NEXT: add sp, #8
104 ; NOFP-NEXT: pop {r7, pc}
106 ; NOFP-AAPCS-LABEL: non_leaf:
107 ; NOFP-AAPCS: @ %bb.0:
108 ; NOFP-AAPCS-NEXT: .save {r7, lr}
109 ; NOFP-AAPCS-NEXT: push {r7, lr}
110 ; NOFP-AAPCS-NEXT: .pad #8
111 ; NOFP-AAPCS-NEXT: sub sp, #8
112 ; NOFP-AAPCS-NEXT: str r0, [sp, #4]
113 ; NOFP-AAPCS-NEXT: bl leaf
114 ; NOFP-AAPCS-NEXT: adds r0, r0, #1
115 ; NOFP-AAPCS-NEXT: add sp, #8
116 ; NOFP-AAPCS-NEXT: pop {r7, pc}
117 %2 = alloca i32, align 4
118 store i32 %0, ptr %2, align 4
119 %3 = load i32, ptr %2, align 4
120 %4 = call noundef i32 @leaf(i32 noundef %3)
121 %5 = add nsw i32 %4, 1
125 declare ptr @llvm.stacksave()
126 define dso_local void @required_fp(i32 %0, i32 %1) {
127 ; FP-LABEL: required_fp:
129 ; FP-NEXT: .save {r4, r6, r7, lr}
130 ; FP-NEXT: push {r4, r6, r7, lr}
131 ; FP-NEXT: .setfp r7, sp, #8
132 ; FP-NEXT: add r7, sp, #8
134 ; FP-NEXT: sub sp, #24
135 ; FP-NEXT: mov r6, sp
136 ; FP-NEXT: mov r2, r6
137 ; FP-NEXT: str r1, [r2, #16]
138 ; FP-NEXT: str r0, [r2, #20]
139 ; FP-NEXT: mov r1, sp
140 ; FP-NEXT: str r1, [r2, #8]
141 ; FP-NEXT: lsls r1, r0, #2
142 ; FP-NEXT: adds r1, r1, #7
143 ; FP-NEXT: movs r3, #7
144 ; FP-NEXT: bics r1, r3
145 ; FP-NEXT: mov r3, sp
146 ; FP-NEXT: subs r1, r3, r1
147 ; FP-NEXT: mov sp, r1
148 ; FP-NEXT: movs r1, #0
149 ; FP-NEXT: str r1, [r6, #4]
150 ; FP-NEXT: str r0, [r2]
151 ; FP-NEXT: subs r6, r7, #7
152 ; FP-NEXT: subs r6, #1
153 ; FP-NEXT: mov sp, r6
154 ; FP-NEXT: pop {r4, r6, r7, pc}
156 ; FP-AAPCS-LABEL: required_fp:
158 ; FP-AAPCS-NEXT: .save {lr}
159 ; FP-AAPCS-NEXT: push {lr}
160 ; FP-AAPCS-NEXT: mov lr, r11
161 ; FP-AAPCS-NEXT: .save {r11}
162 ; FP-AAPCS-NEXT: push {lr}
163 ; FP-AAPCS-NEXT: .setfp r11, sp
164 ; FP-AAPCS-NEXT: mov r11, sp
165 ; FP-AAPCS-NEXT: .save {r4, r6}
166 ; FP-AAPCS-NEXT: push {r4, r6}
167 ; FP-AAPCS-NEXT: .pad #24
168 ; FP-AAPCS-NEXT: sub sp, #24
169 ; FP-AAPCS-NEXT: mov r6, sp
170 ; FP-AAPCS-NEXT: mov r2, r6
171 ; FP-AAPCS-NEXT: str r1, [r2, #16]
172 ; FP-AAPCS-NEXT: str r0, [r2, #20]
173 ; FP-AAPCS-NEXT: mov r1, sp
174 ; FP-AAPCS-NEXT: str r1, [r2, #8]
175 ; FP-AAPCS-NEXT: lsls r1, r0, #2
176 ; FP-AAPCS-NEXT: adds r1, r1, #7
177 ; FP-AAPCS-NEXT: movs r3, #7
178 ; FP-AAPCS-NEXT: bics r1, r3
179 ; FP-AAPCS-NEXT: mov r3, sp
180 ; FP-AAPCS-NEXT: subs r1, r3, r1
181 ; FP-AAPCS-NEXT: mov sp, r1
182 ; FP-AAPCS-NEXT: movs r1, #0
183 ; FP-AAPCS-NEXT: str r1, [r6, #4]
184 ; FP-AAPCS-NEXT: str r0, [r2]
185 ; FP-AAPCS-NEXT: mov r6, r11
186 ; FP-AAPCS-NEXT: subs r6, #8
187 ; FP-AAPCS-NEXT: mov sp, r6
188 ; FP-AAPCS-NEXT: pop {r4, r6}
189 ; FP-AAPCS-NEXT: pop {r0}
190 ; FP-AAPCS-NEXT: mov r11, r0
191 ; FP-AAPCS-NEXT: pop {pc}
193 ; NOFP-LABEL: required_fp:
195 ; NOFP-NEXT: .save {r4, r6, r7, lr}
196 ; NOFP-NEXT: push {r4, r6, r7, lr}
197 ; NOFP-NEXT: .setfp r7, sp, #8
198 ; NOFP-NEXT: add r7, sp, #8
199 ; NOFP-NEXT: .pad #24
200 ; NOFP-NEXT: sub sp, #24
201 ; NOFP-NEXT: mov r6, sp
202 ; NOFP-NEXT: mov r2, r6
203 ; NOFP-NEXT: str r1, [r2, #16]
204 ; NOFP-NEXT: str r0, [r2, #20]
205 ; NOFP-NEXT: mov r1, sp
206 ; NOFP-NEXT: str r1, [r2, #8]
207 ; NOFP-NEXT: lsls r1, r0, #2
208 ; NOFP-NEXT: adds r1, r1, #7
209 ; NOFP-NEXT: movs r3, #7
210 ; NOFP-NEXT: bics r1, r3
211 ; NOFP-NEXT: mov r3, sp
212 ; NOFP-NEXT: subs r1, r3, r1
213 ; NOFP-NEXT: mov sp, r1
214 ; NOFP-NEXT: movs r1, #0
215 ; NOFP-NEXT: str r1, [r6, #4]
216 ; NOFP-NEXT: str r0, [r2]
217 ; NOFP-NEXT: subs r6, r7, #7
218 ; NOFP-NEXT: subs r6, #1
219 ; NOFP-NEXT: mov sp, r6
220 ; NOFP-NEXT: pop {r4, r6, r7, pc}
222 ; NOFP-AAPCS-LABEL: required_fp:
223 ; NOFP-AAPCS: @ %bb.0:
224 ; NOFP-AAPCS-NEXT: .save {lr}
225 ; NOFP-AAPCS-NEXT: push {lr}
226 ; NOFP-AAPCS-NEXT: mov lr, r11
227 ; NOFP-AAPCS-NEXT: .save {r11}
228 ; NOFP-AAPCS-NEXT: push {lr}
229 ; NOFP-AAPCS-NEXT: .setfp r11, sp
230 ; NOFP-AAPCS-NEXT: mov r11, sp
231 ; NOFP-AAPCS-NEXT: .save {r4, r6}
232 ; NOFP-AAPCS-NEXT: push {r4, r6}
233 ; NOFP-AAPCS-NEXT: .pad #24
234 ; NOFP-AAPCS-NEXT: sub sp, #24
235 ; NOFP-AAPCS-NEXT: mov r6, sp
236 ; NOFP-AAPCS-NEXT: mov r2, r6
237 ; NOFP-AAPCS-NEXT: str r1, [r2, #16]
238 ; NOFP-AAPCS-NEXT: str r0, [r2, #20]
239 ; NOFP-AAPCS-NEXT: mov r1, sp
240 ; NOFP-AAPCS-NEXT: str r1, [r2, #8]
241 ; NOFP-AAPCS-NEXT: lsls r1, r0, #2
242 ; NOFP-AAPCS-NEXT: adds r1, r1, #7
243 ; NOFP-AAPCS-NEXT: movs r3, #7
244 ; NOFP-AAPCS-NEXT: bics r1, r3
245 ; NOFP-AAPCS-NEXT: mov r3, sp
246 ; NOFP-AAPCS-NEXT: subs r1, r3, r1
247 ; NOFP-AAPCS-NEXT: mov sp, r1
248 ; NOFP-AAPCS-NEXT: movs r1, #0
249 ; NOFP-AAPCS-NEXT: str r1, [r6, #4]
250 ; NOFP-AAPCS-NEXT: str r0, [r2]
251 ; NOFP-AAPCS-NEXT: mov r6, r11
252 ; NOFP-AAPCS-NEXT: subs r6, #8
253 ; NOFP-AAPCS-NEXT: mov sp, r6
254 ; NOFP-AAPCS-NEXT: pop {r4, r6}
255 ; NOFP-AAPCS-NEXT: pop {r0}
256 ; NOFP-AAPCS-NEXT: mov r11, r0
257 ; NOFP-AAPCS-NEXT: pop {pc}
258 %3 = alloca i32, align 4
259 %4 = alloca i32, align 4
260 %5 = alloca ptr, align 8
261 %6 = alloca i64, align 8
262 store i32 %0, ptr %3, align 4
263 store i32 %1, ptr %4, align 4
264 %7 = load i32, ptr %3, align 4
265 %8 = zext i32 %7 to i64
266 %9 = call ptr @llvm.stacksave()
267 store ptr %9, ptr %5, align 8
268 %10 = alloca i32, i64 %8, align 4
269 store i64 %8, ptr %6, align 8