1 ; RUN: llc -mtriple arm-arm-none-eabi -filetype asm -o - %s -frame-pointer=all | FileCheck %s --check-prefixes=FP,LEAF-FP
2 ; RUN: llc -mtriple arm-arm-none-eabi -filetype asm -o - %s -frame-pointer=all -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-FP-AAPCS
3 ; RUN: llc -mtriple arm-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf | FileCheck %s --check-prefixes=FP,LEAF-NOFP
4 ; RUN: llc -mtriple arm-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-NOFP-AAPCS
5 ; RUN: llc -mtriple arm-arm-none-eabi -filetype asm -o - %s -frame-pointer=none | FileCheck %s --check-prefixes=NOFP,LEAF-NOFP
6 ; RUN: llc -mtriple arm-arm-none-eabi -filetype asm -o - %s -frame-pointer=none -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=NOFP-AAPCS,LEAF-NOFP-AAPCS
7 ; RUN: llc -mtriple arm-arm-none-eabi -filetype asm -o - %s -frame-pointer=reserved | FileCheck %s --check-prefixes=NOFP,LEAF-NOFP
8 ; RUN: llc -mtriple arm-arm-none-eabi -filetype asm -o - %s -frame-pointer=reserved -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=NOFP-AAPCS,LEAF-NOFP-AAPCS
10 define dso_local noundef i32 @leaf(i32 noundef %0) {
11 ; LEAF-FP-LABEL: leaf:
13 ; LEAF-FP-NEXT: .pad #4
14 ; LEAF-FP-NEXT: sub sp, sp, #4
15 ; LEAF-FP-NEXT: str r0, [sp]
16 ; LEAF-FP-NEXT: add r0, r0, #4
17 ; LEAF-FP-NEXT: add sp, sp, #4
18 ; LEAF-FP-NEXT: mov pc, lr
20 ; LEAF-FP-AAPCS-LABEL: leaf:
21 ; LEAF-FP-AAPCS: @ %bb.0:
22 ; LEAF-FP-AAPCS-NEXT: .save {r11, lr}
23 ; LEAF-FP-AAPCS-NEXT: push {r11, lr}
24 ; LEAF-FP-AAPCS-NEXT: .setfp r11, sp
25 ; LEAF-FP-AAPCS-NEXT: mov r11, sp
26 ; LEAF-FP-AAPCS-NEXT: push {r0}
27 ; LEAF-FP-AAPCS-NEXT: add r0, r0, #4
28 ; LEAF-FP-AAPCS-NEXT: mov sp, r11
29 ; LEAF-FP-AAPCS-NEXT: pop {r11, lr}
30 ; LEAF-FP-AAPCS-NEXT: mov pc, lr
32 ; LEAF-NOFP-LABEL: leaf:
34 ; LEAF-NOFP-NEXT: .pad #4
35 ; LEAF-NOFP-NEXT: sub sp, sp, #4
36 ; LEAF-NOFP-NEXT: str r0, [sp]
37 ; LEAF-NOFP-NEXT: add r0, r0, #4
38 ; LEAF-NOFP-NEXT: add sp, sp, #4
39 ; LEAF-NOFP-NEXT: mov pc, lr
41 ; LEAF-NOFP-AAPCS-LABEL: leaf:
42 ; LEAF-NOFP-AAPCS: @ %bb.0:
43 ; LEAF-NOFP-AAPCS-NEXT: .pad #4
44 ; LEAF-NOFP-AAPCS-NEXT: sub sp, sp, #4
45 ; LEAF-NOFP-AAPCS-NEXT: str r0, [sp]
46 ; LEAF-NOFP-AAPCS-NEXT: add r0, r0, #4
47 ; LEAF-NOFP-AAPCS-NEXT: add sp, sp, #4
48 ; LEAF-NOFP-AAPCS-NEXT: mov pc, lr
49 %2 = alloca i32, align 4
50 store i32 %0, ptr %2, align 4
51 %3 = load i32, ptr %2, align 4
52 %4 = add nsw i32 %3, 4
56 define dso_local noundef i32 @non_leaf(i32 noundef %0) {
59 ; FP-NEXT: .save {r11, lr}
60 ; FP-NEXT: push {r11, lr}
61 ; FP-NEXT: .setfp r11, sp
62 ; FP-NEXT: mov r11, sp
64 ; FP-NEXT: sub sp, sp, #8
65 ; FP-NEXT: str r0, [sp, #4]
67 ; FP-NEXT: add r0, r0, #1
68 ; FP-NEXT: mov sp, r11
69 ; FP-NEXT: pop {r11, lr}
72 ; FP-AAPCS-LABEL: non_leaf:
74 ; FP-AAPCS-NEXT: .save {r11, lr}
75 ; FP-AAPCS-NEXT: push {r11, lr}
76 ; FP-AAPCS-NEXT: .setfp r11, sp
77 ; FP-AAPCS-NEXT: mov r11, sp
78 ; FP-AAPCS-NEXT: .pad #8
79 ; FP-AAPCS-NEXT: sub sp, sp, #8
80 ; FP-AAPCS-NEXT: str r0, [sp, #4]
81 ; FP-AAPCS-NEXT: bl leaf
82 ; FP-AAPCS-NEXT: add r0, r0, #1
83 ; FP-AAPCS-NEXT: mov sp, r11
84 ; FP-AAPCS-NEXT: pop {r11, lr}
85 ; FP-AAPCS-NEXT: mov pc, lr
87 ; NOFP-LABEL: non_leaf:
89 ; NOFP-NEXT: .save {r11, lr}
90 ; NOFP-NEXT: push {r11, lr}
92 ; NOFP-NEXT: sub sp, sp, #8
93 ; NOFP-NEXT: str r0, [sp, #4]
95 ; NOFP-NEXT: add r0, r0, #1
96 ; NOFP-NEXT: add sp, sp, #8
97 ; NOFP-NEXT: pop {r11, lr}
98 ; NOFP-NEXT: mov pc, lr
100 ; NOFP-AAPCS-LABEL: non_leaf:
101 ; NOFP-AAPCS: @ %bb.0:
102 ; NOFP-AAPCS-NEXT: .save {r11, lr}
103 ; NOFP-AAPCS-NEXT: push {r11, lr}
104 ; NOFP-AAPCS-NEXT: .pad #8
105 ; NOFP-AAPCS-NEXT: sub sp, sp, #8
106 ; NOFP-AAPCS-NEXT: str r0, [sp, #4]
107 ; NOFP-AAPCS-NEXT: bl leaf
108 ; NOFP-AAPCS-NEXT: add r0, r0, #1
109 ; NOFP-AAPCS-NEXT: add sp, sp, #8
110 ; NOFP-AAPCS-NEXT: pop {r11, lr}
111 ; NOFP-AAPCS-NEXT: mov pc, lr
112 %2 = alloca i32, align 4
113 store i32 %0, ptr %2, align 4
114 %3 = load i32, ptr %2, align 4
115 %4 = call noundef i32 @leaf(i32 noundef %3)
116 %5 = add nsw i32 %4, 1
120 declare ptr @llvm.stacksave()
121 define dso_local void @required_fp(i32 %0, i32 %1) {
122 ; LEAF-FP-LABEL: required_fp:
124 ; LEAF-FP-NEXT: .save {r4, r5, r11, lr}
125 ; LEAF-FP-NEXT: push {r4, r5, r11, lr}
126 ; LEAF-FP-NEXT: .setfp r11, sp, #8
127 ; LEAF-FP-NEXT: add r11, sp, #8
128 ; LEAF-FP-NEXT: .pad #24
129 ; LEAF-FP-NEXT: sub sp, sp, #24
130 ; LEAF-FP-NEXT: str r1, [r11, #-16]
131 ; LEAF-FP-NEXT: mov r1, #7
132 ; LEAF-FP-NEXT: add r1, r1, r0, lsl #2
133 ; LEAF-FP-NEXT: str r0, [r11, #-12]
134 ; LEAF-FP-NEXT: bic r1, r1, #7
135 ; LEAF-FP-NEXT: str sp, [r11, #-24]
136 ; LEAF-FP-NEXT: sub sp, sp, r1
137 ; LEAF-FP-NEXT: mov r1, #0
138 ; LEAF-FP-NEXT: str r0, [r11, #-32]
139 ; LEAF-FP-NEXT: str r1, [r11, #-28]
140 ; LEAF-FP-NEXT: sub sp, r11, #8
141 ; LEAF-FP-NEXT: pop {r4, r5, r11, lr}
142 ; LEAF-FP-NEXT: mov pc, lr
144 ; LEAF-FP-AAPCS-LABEL: required_fp:
145 ; LEAF-FP-AAPCS: @ %bb.0:
146 ; LEAF-FP-AAPCS-NEXT: .save {r4, r5, r11, lr}
147 ; LEAF-FP-AAPCS-NEXT: push {r4, r5, r11, lr}
148 ; LEAF-FP-AAPCS-NEXT: .setfp r11, sp, #8
149 ; LEAF-FP-AAPCS-NEXT: add r11, sp, #8
150 ; LEAF-FP-AAPCS-NEXT: .pad #24
151 ; LEAF-FP-AAPCS-NEXT: sub sp, sp, #24
152 ; LEAF-FP-AAPCS-NEXT: str r1, [r11, #-16]
153 ; LEAF-FP-AAPCS-NEXT: mov r1, #7
154 ; LEAF-FP-AAPCS-NEXT: add r1, r1, r0, lsl #2
155 ; LEAF-FP-AAPCS-NEXT: str r0, [r11, #-12]
156 ; LEAF-FP-AAPCS-NEXT: bic r1, r1, #7
157 ; LEAF-FP-AAPCS-NEXT: str sp, [r11, #-24]
158 ; LEAF-FP-AAPCS-NEXT: sub sp, sp, r1
159 ; LEAF-FP-AAPCS-NEXT: mov r1, #0
160 ; LEAF-FP-AAPCS-NEXT: str r0, [r11, #-32]
161 ; LEAF-FP-AAPCS-NEXT: str r1, [r11, #-28]
162 ; LEAF-FP-AAPCS-NEXT: sub sp, r11, #8
163 ; LEAF-FP-AAPCS-NEXT: pop {r4, r5, r11, lr}
164 ; LEAF-FP-AAPCS-NEXT: mov pc, lr
166 ; LEAF-NOFP-LABEL: required_fp:
167 ; LEAF-NOFP: @ %bb.0:
168 ; LEAF-NOFP-NEXT: .save {r4, r5, r11}
169 ; LEAF-NOFP-NEXT: push {r4, r5, r11}
170 ; LEAF-NOFP-NEXT: .setfp r11, sp, #8
171 ; LEAF-NOFP-NEXT: add r11, sp, #8
172 ; LEAF-NOFP-NEXT: .pad #20
173 ; LEAF-NOFP-NEXT: sub sp, sp, #20
174 ; LEAF-NOFP-NEXT: str r1, [r11, #-16]
175 ; LEAF-NOFP-NEXT: mov r1, #7
176 ; LEAF-NOFP-NEXT: add r1, r1, r0, lsl #2
177 ; LEAF-NOFP-NEXT: str r0, [r11, #-12]
178 ; LEAF-NOFP-NEXT: bic r1, r1, #7
179 ; LEAF-NOFP-NEXT: str sp, [r11, #-20]
180 ; LEAF-NOFP-NEXT: sub sp, sp, r1
181 ; LEAF-NOFP-NEXT: mov r1, #0
182 ; LEAF-NOFP-NEXT: str r0, [r11, #-28]
183 ; LEAF-NOFP-NEXT: str r1, [r11, #-24]
184 ; LEAF-NOFP-NEXT: sub sp, r11, #8
185 ; LEAF-NOFP-NEXT: pop {r4, r5, r11}
186 ; LEAF-NOFP-NEXT: mov pc, lr
188 ; LEAF-NOFP-AAPCS-LABEL: required_fp:
189 ; LEAF-NOFP-AAPCS: @ %bb.0:
190 ; LEAF-NOFP-AAPCS-NEXT: .save {r4, r5, r11, lr}
191 ; LEAF-NOFP-AAPCS-NEXT: push {r4, r5, r11, lr}
192 ; LEAF-NOFP-AAPCS-NEXT: .setfp r11, sp, #8
193 ; LEAF-NOFP-AAPCS-NEXT: add r11, sp, #8
194 ; LEAF-NOFP-AAPCS-NEXT: .pad #24
195 ; LEAF-NOFP-AAPCS-NEXT: sub sp, sp, #24
196 ; LEAF-NOFP-AAPCS-NEXT: str r1, [r11, #-16]
197 ; LEAF-NOFP-AAPCS-NEXT: mov r1, #7
198 ; LEAF-NOFP-AAPCS-NEXT: add r1, r1, r0, lsl #2
199 ; LEAF-NOFP-AAPCS-NEXT: str r0, [r11, #-12]
200 ; LEAF-NOFP-AAPCS-NEXT: bic r1, r1, #7
201 ; LEAF-NOFP-AAPCS-NEXT: str sp, [r11, #-24]
202 ; LEAF-NOFP-AAPCS-NEXT: sub sp, sp, r1
203 ; LEAF-NOFP-AAPCS-NEXT: mov r1, #0
204 ; LEAF-NOFP-AAPCS-NEXT: str r0, [r11, #-32]
205 ; LEAF-NOFP-AAPCS-NEXT: str r1, [r11, #-28]
206 ; LEAF-NOFP-AAPCS-NEXT: sub sp, r11, #8
207 ; LEAF-NOFP-AAPCS-NEXT: pop {r4, r5, r11, lr}
208 ; LEAF-NOFP-AAPCS-NEXT: mov pc, lr
209 %3 = alloca i32, align 4
210 %4 = alloca i32, align 4
211 %5 = alloca ptr, align 8
212 %6 = alloca i64, align 8
213 store i32 %0, ptr %3, align 4
214 store i32 %1, ptr %4, align 4
215 %7 = load i32, ptr %3, align 4
216 %8 = zext i32 %7 to i64
217 %9 = call ptr @llvm.stacksave()
218 store ptr %9, ptr %5, align 8
219 %10 = alloca i32, i64 %8, align 4
220 store i64 %8, ptr %6, align 8