1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=ve | FileCheck %s
3 ; RUN: llc < %s -mtriple=ve -relocation-model=pic \
4 ; RUN: | FileCheck %s --check-prefix=PIC
6 ;;; Check stack frame allocation of a function which does not calls other
7 ;;; functions under following conditions and combinations of them:
8 ;;; - access variable or not
9 ;;; - no stack object, a stack object using BP, or a stack object not using BP
10 ;;; - isPositionIndependent or not
12 @data = external global i8, align 1
14 ; Function Attrs: norecurse nounwind readnone
15 define ptr @test_frame0(ptr nocapture readnone %0, ptr readnone returned %1) {
16 ; CHECK-LABEL: test_frame0:
18 ; CHECK-NEXT: or %s0, 0, %s1
19 ; CHECK-NEXT: b.l.t (, %s10)
21 ; PIC-LABEL: test_frame0:
23 ; PIC-NEXT: or %s0, 0, %s1
24 ; PIC-NEXT: b.l.t (, %s10)
28 ; Function Attrs: nofree nounwind
29 define nonnull ptr @test_frame32(ptr nocapture readonly %0) {
30 ; CHECK-LABEL: test_frame32:
32 ; CHECK-NEXT: adds.l %s11, -32, %s11
33 ; CHECK-NEXT: brge.l.t %s11, %s8, .LBB1_2
34 ; CHECK-NEXT: # %bb.1:
35 ; CHECK-NEXT: ld %s61, 24(, %s14)
36 ; CHECK-NEXT: or %s62, 0, %s0
37 ; CHECK-NEXT: lea %s63, 315
38 ; CHECK-NEXT: shm.l %s63, (%s61)
39 ; CHECK-NEXT: shm.l %s8, 8(%s61)
40 ; CHECK-NEXT: shm.l %s11, 16(%s61)
42 ; CHECK-NEXT: or %s0, 0, %s62
43 ; CHECK-NEXT: .LBB1_2:
44 ; CHECK-NEXT: ld1b.zx %s1, (, %s0)
45 ; CHECK-NEXT: lea %s0, (, %s11)
46 ; CHECK-NEXT: st1b %s1, (, %s11)
47 ; CHECK-NEXT: adds.l %s11, 32, %s11
48 ; CHECK-NEXT: b.l.t (, %s10)
50 ; PIC-LABEL: test_frame32:
52 ; PIC-NEXT: adds.l %s11, -32, %s11
53 ; PIC-NEXT: brge.l.t %s11, %s8, .LBB1_2
55 ; PIC-NEXT: ld %s61, 24(, %s14)
56 ; PIC-NEXT: or %s62, 0, %s0
57 ; PIC-NEXT: lea %s63, 315
58 ; PIC-NEXT: shm.l %s63, (%s61)
59 ; PIC-NEXT: shm.l %s8, 8(%s61)
60 ; PIC-NEXT: shm.l %s11, 16(%s61)
62 ; PIC-NEXT: or %s0, 0, %s62
64 ; PIC-NEXT: ld1b.zx %s1, (, %s0)
65 ; PIC-NEXT: lea %s0, (, %s11)
66 ; PIC-NEXT: st1b %s1, (, %s11)
67 ; PIC-NEXT: adds.l %s11, 32, %s11
68 ; PIC-NEXT: b.l.t (, %s10)
69 %2 = alloca [32 x i8], align 1
70 call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2)
71 %3 = load i8, ptr %0, align 1
72 store volatile i8 %3, ptr %2, align 1
73 call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2)
77 ; Function Attrs: argmemonly nofree nosync nounwind willreturn
78 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
80 ; Function Attrs: argmemonly nofree nosync nounwind willreturn
81 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
83 ; Function Attrs: nofree nounwind
84 define noalias nonnull ptr @test_align32(i32 signext %0, ptr nocapture readonly %1) {
85 ; CHECK-LABEL: test_align32:
87 ; CHECK-NEXT: st %s9, (, %s11)
88 ; CHECK-NEXT: st %s10, 8(, %s11)
89 ; CHECK-NEXT: st %s17, 40(, %s11)
90 ; CHECK-NEXT: or %s9, 0, %s11
91 ; CHECK-NEXT: lea %s11, -288(, %s11)
92 ; CHECK-NEXT: and %s11, %s11, (59)1
93 ; CHECK-NEXT: or %s17, 0, %s11
94 ; CHECK-NEXT: brge.l.t %s11, %s8, .LBB2_2
95 ; CHECK-NEXT: # %bb.1:
96 ; CHECK-NEXT: ld %s61, 24(, %s14)
97 ; CHECK-NEXT: or %s62, 0, %s0
98 ; CHECK-NEXT: lea %s63, 315
99 ; CHECK-NEXT: shm.l %s63, (%s61)
100 ; CHECK-NEXT: shm.l %s8, 8(%s61)
101 ; CHECK-NEXT: shm.l %s11, 16(%s61)
103 ; CHECK-NEXT: or %s0, 0, %s62
104 ; CHECK-NEXT: .LBB2_2:
105 ; CHECK-NEXT: or %s2, 0, %s1
106 ; CHECK-NEXT: lea %s0, 15(, %s0)
107 ; CHECK-NEXT: and %s0, -16, %s0
108 ; CHECK-NEXT: lea %s1, __ve_grow_stack_align@lo
109 ; CHECK-NEXT: and %s1, %s1, (32)0
110 ; CHECK-NEXT: lea.sl %s12, __ve_grow_stack_align@hi(, %s1)
111 ; CHECK-NEXT: or %s1, -32, (0)1
112 ; CHECK-NEXT: bsic %s10, (, %s12)
113 ; CHECK-NEXT: lea %s0, 240(, %s11)
114 ; CHECK-NEXT: ld1b.zx %s1, (, %s2)
115 ; CHECK-NEXT: lea %s0, 31(, %s0)
116 ; CHECK-NEXT: and %s2, -32, %s0
117 ; CHECK-NEXT: lea %s0, 256(, %s17)
118 ; CHECK-NEXT: st1b %s1, (, %s2)
119 ; CHECK-NEXT: or %s11, 0, %s9
120 ; CHECK-NEXT: ld %s17, 40(, %s11)
121 ; CHECK-NEXT: ld %s10, 8(, %s11)
122 ; CHECK-NEXT: ld %s9, (, %s11)
123 ; CHECK-NEXT: b.l.t (, %s10)
125 ; PIC-LABEL: test_align32:
127 ; PIC-NEXT: st %s9, (, %s11)
128 ; PIC-NEXT: st %s10, 8(, %s11)
129 ; PIC-NEXT: st %s15, 24(, %s11)
130 ; PIC-NEXT: st %s16, 32(, %s11)
131 ; PIC-NEXT: st %s17, 40(, %s11)
132 ; PIC-NEXT: or %s9, 0, %s11
133 ; PIC-NEXT: lea %s11, -288(, %s11)
134 ; PIC-NEXT: and %s11, %s11, (59)1
135 ; PIC-NEXT: or %s17, 0, %s11
136 ; PIC-NEXT: brge.l.t %s11, %s8, .LBB2_2
138 ; PIC-NEXT: ld %s61, 24(, %s14)
139 ; PIC-NEXT: or %s62, 0, %s0
140 ; PIC-NEXT: lea %s63, 315
141 ; PIC-NEXT: shm.l %s63, (%s61)
142 ; PIC-NEXT: shm.l %s8, 8(%s61)
143 ; PIC-NEXT: shm.l %s11, 16(%s61)
145 ; PIC-NEXT: or %s0, 0, %s62
147 ; PIC-NEXT: or %s2, 0, %s1
148 ; PIC-NEXT: lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24)
149 ; PIC-NEXT: and %s15, %s15, (32)0
151 ; PIC-NEXT: lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15)
152 ; PIC-NEXT: lea %s0, 15(, %s0)
153 ; PIC-NEXT: and %s0, -16, %s0
154 ; PIC-NEXT: lea %s12, __ve_grow_stack_align@plt_lo(-24)
155 ; PIC-NEXT: and %s12, %s12, (32)0
157 ; PIC-NEXT: lea.sl %s12, __ve_grow_stack_align@plt_hi(%s16, %s12)
158 ; PIC-NEXT: or %s1, -32, (0)1
159 ; PIC-NEXT: bsic %s10, (, %s12)
160 ; PIC-NEXT: lea %s0, 240(, %s11)
161 ; PIC-NEXT: ld1b.zx %s1, (, %s2)
162 ; PIC-NEXT: lea %s0, 31(, %s0)
163 ; PIC-NEXT: and %s2, -32, %s0
164 ; PIC-NEXT: lea %s0, 256(, %s17)
165 ; PIC-NEXT: st1b %s1, (, %s2)
166 ; PIC-NEXT: or %s11, 0, %s9
167 ; PIC-NEXT: ld %s17, 40(, %s11)
168 ; PIC-NEXT: ld %s16, 32(, %s11)
169 ; PIC-NEXT: ld %s15, 24(, %s11)
170 ; PIC-NEXT: ld %s10, 8(, %s11)
171 ; PIC-NEXT: ld %s9, (, %s11)
172 ; PIC-NEXT: b.l.t (, %s10)
173 %3 = alloca [32 x i8], align 32
174 call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3)
175 %4 = sext i32 %0 to i64
176 %5 = alloca i8, i64 %4, align 32
177 %6 = load i8, ptr %1, align 1
178 store volatile i8 %6, ptr %5, align 32
179 call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3)
183 ; Function Attrs: nofree norecurse nounwind
184 define ptr @test_frame0_var(ptr returned %0, ptr nocapture readnone %1) {
185 ; CHECK-LABEL: test_frame0_var:
187 ; CHECK-NEXT: lea %s1, data@lo
188 ; CHECK-NEXT: and %s1, %s1, (32)0
189 ; CHECK-NEXT: lea.sl %s1, data@hi(, %s1)
190 ; CHECK-NEXT: ld1b.zx %s1, (, %s1)
191 ; CHECK-NEXT: st1b %s1, (, %s0)
192 ; CHECK-NEXT: b.l.t (, %s10)
194 ; PIC-LABEL: test_frame0_var:
196 ; PIC-NEXT: st %s15, 24(, %s11)
197 ; PIC-NEXT: st %s16, 32(, %s11)
198 ; PIC-NEXT: lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24)
199 ; PIC-NEXT: and %s15, %s15, (32)0
201 ; PIC-NEXT: lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15)
202 ; PIC-NEXT: lea %s1, data@got_lo
203 ; PIC-NEXT: and %s1, %s1, (32)0
204 ; PIC-NEXT: lea.sl %s1, data@got_hi(, %s1)
205 ; PIC-NEXT: ld %s1, (%s1, %s15)
206 ; PIC-NEXT: ld1b.zx %s1, (, %s1)
207 ; PIC-NEXT: st1b %s1, (, %s0)
208 ; PIC-NEXT: ld %s16, 32(, %s11)
209 ; PIC-NEXT: ld %s15, 24(, %s11)
210 ; PIC-NEXT: b.l.t (, %s10)
211 %3 = load i8, ptr @data, align 1
212 store i8 %3, ptr %0, align 1
216 ; Function Attrs: nofree nounwind
217 define nonnull ptr @test_frame32_var(ptr nocapture readnone %0) {
218 ; CHECK-LABEL: test_frame32_var:
220 ; CHECK-NEXT: adds.l %s11, -32, %s11
221 ; CHECK-NEXT: brge.l.t %s11, %s8, .LBB4_2
222 ; CHECK-NEXT: # %bb.1:
223 ; CHECK-NEXT: ld %s61, 24(, %s14)
224 ; CHECK-NEXT: or %s62, 0, %s0
225 ; CHECK-NEXT: lea %s63, 315
226 ; CHECK-NEXT: shm.l %s63, (%s61)
227 ; CHECK-NEXT: shm.l %s8, 8(%s61)
228 ; CHECK-NEXT: shm.l %s11, 16(%s61)
230 ; CHECK-NEXT: or %s0, 0, %s62
231 ; CHECK-NEXT: .LBB4_2:
232 ; CHECK-NEXT: lea %s0, data@lo
233 ; CHECK-NEXT: and %s0, %s0, (32)0
234 ; CHECK-NEXT: lea.sl %s0, data@hi(, %s0)
235 ; CHECK-NEXT: ld1b.zx %s1, (, %s0)
236 ; CHECK-NEXT: lea %s0, (, %s11)
237 ; CHECK-NEXT: st1b %s1, (, %s11)
238 ; CHECK-NEXT: adds.l %s11, 32, %s11
239 ; CHECK-NEXT: b.l.t (, %s10)
241 ; PIC-LABEL: test_frame32_var:
243 ; PIC-NEXT: st %s15, 24(, %s11)
244 ; PIC-NEXT: st %s16, 32(, %s11)
245 ; PIC-NEXT: adds.l %s11, -32, %s11
246 ; PIC-NEXT: brge.l.t %s11, %s8, .LBB4_2
248 ; PIC-NEXT: ld %s61, 24(, %s14)
249 ; PIC-NEXT: or %s62, 0, %s0
250 ; PIC-NEXT: lea %s63, 315
251 ; PIC-NEXT: shm.l %s63, (%s61)
252 ; PIC-NEXT: shm.l %s8, 8(%s61)
253 ; PIC-NEXT: shm.l %s11, 16(%s61)
255 ; PIC-NEXT: or %s0, 0, %s62
257 ; PIC-NEXT: lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24)
258 ; PIC-NEXT: and %s15, %s15, (32)0
260 ; PIC-NEXT: lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15)
261 ; PIC-NEXT: lea %s0, data@got_lo
262 ; PIC-NEXT: and %s0, %s0, (32)0
263 ; PIC-NEXT: lea.sl %s0, data@got_hi(, %s0)
264 ; PIC-NEXT: ld %s0, (%s0, %s15)
265 ; PIC-NEXT: ld1b.zx %s1, (, %s0)
266 ; PIC-NEXT: lea %s0, (, %s11)
267 ; PIC-NEXT: st1b %s1, (, %s11)
268 ; PIC-NEXT: adds.l %s11, 32, %s11
269 ; PIC-NEXT: ld %s16, 32(, %s11)
270 ; PIC-NEXT: ld %s15, 24(, %s11)
271 ; PIC-NEXT: b.l.t (, %s10)
272 %2 = alloca [32 x i8], align 1
273 call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2)
274 %3 = load i8, ptr @data, align 1
275 store volatile i8 %3, ptr %2, align 1
276 call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2)
280 ; Function Attrs: nofree nounwind
281 define noalias nonnull ptr @test_align32_var(i32 signext %0, ptr nocapture readonly %1) {
282 ; CHECK-LABEL: test_align32_var:
284 ; CHECK-NEXT: st %s9, (, %s11)
285 ; CHECK-NEXT: st %s10, 8(, %s11)
286 ; CHECK-NEXT: st %s17, 40(, %s11)
287 ; CHECK-NEXT: or %s9, 0, %s11
288 ; CHECK-NEXT: lea %s11, -288(, %s11)
289 ; CHECK-NEXT: and %s11, %s11, (59)1
290 ; CHECK-NEXT: or %s17, 0, %s11
291 ; CHECK-NEXT: brge.l.t %s11, %s8, .LBB5_2
292 ; CHECK-NEXT: # %bb.1:
293 ; CHECK-NEXT: ld %s61, 24(, %s14)
294 ; CHECK-NEXT: or %s62, 0, %s0
295 ; CHECK-NEXT: lea %s63, 315
296 ; CHECK-NEXT: shm.l %s63, (%s61)
297 ; CHECK-NEXT: shm.l %s8, 8(%s61)
298 ; CHECK-NEXT: shm.l %s11, 16(%s61)
300 ; CHECK-NEXT: or %s0, 0, %s62
301 ; CHECK-NEXT: .LBB5_2:
302 ; CHECK-NEXT: or %s2, 0, %s1
303 ; CHECK-NEXT: lea %s0, 15(, %s0)
304 ; CHECK-NEXT: and %s0, -16, %s0
305 ; CHECK-NEXT: lea %s1, __ve_grow_stack_align@lo
306 ; CHECK-NEXT: and %s1, %s1, (32)0
307 ; CHECK-NEXT: lea.sl %s12, __ve_grow_stack_align@hi(, %s1)
308 ; CHECK-NEXT: or %s1, -32, (0)1
309 ; CHECK-NEXT: bsic %s10, (, %s12)
310 ; CHECK-NEXT: lea %s0, 240(, %s11)
311 ; CHECK-NEXT: ld1b.zx %s1, (, %s2)
312 ; CHECK-NEXT: lea %s0, 31(, %s0)
313 ; CHECK-NEXT: and %s2, -32, %s0
314 ; CHECK-NEXT: lea %s0, 256(, %s17)
315 ; CHECK-NEXT: st1b %s1, (, %s2)
316 ; CHECK-NEXT: or %s11, 0, %s9
317 ; CHECK-NEXT: ld %s17, 40(, %s11)
318 ; CHECK-NEXT: ld %s10, 8(, %s11)
319 ; CHECK-NEXT: ld %s9, (, %s11)
320 ; CHECK-NEXT: b.l.t (, %s10)
322 ; PIC-LABEL: test_align32_var:
324 ; PIC-NEXT: st %s9, (, %s11)
325 ; PIC-NEXT: st %s10, 8(, %s11)
326 ; PIC-NEXT: st %s15, 24(, %s11)
327 ; PIC-NEXT: st %s16, 32(, %s11)
328 ; PIC-NEXT: st %s17, 40(, %s11)
329 ; PIC-NEXT: or %s9, 0, %s11
330 ; PIC-NEXT: lea %s11, -288(, %s11)
331 ; PIC-NEXT: and %s11, %s11, (59)1
332 ; PIC-NEXT: or %s17, 0, %s11
333 ; PIC-NEXT: brge.l.t %s11, %s8, .LBB5_2
335 ; PIC-NEXT: ld %s61, 24(, %s14)
336 ; PIC-NEXT: or %s62, 0, %s0
337 ; PIC-NEXT: lea %s63, 315
338 ; PIC-NEXT: shm.l %s63, (%s61)
339 ; PIC-NEXT: shm.l %s8, 8(%s61)
340 ; PIC-NEXT: shm.l %s11, 16(%s61)
342 ; PIC-NEXT: or %s0, 0, %s62
344 ; PIC-NEXT: or %s2, 0, %s1
345 ; PIC-NEXT: lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24)
346 ; PIC-NEXT: and %s15, %s15, (32)0
348 ; PIC-NEXT: lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15)
349 ; PIC-NEXT: lea %s0, 15(, %s0)
350 ; PIC-NEXT: and %s0, -16, %s0
351 ; PIC-NEXT: lea %s12, __ve_grow_stack_align@plt_lo(-24)
352 ; PIC-NEXT: and %s12, %s12, (32)0
354 ; PIC-NEXT: lea.sl %s12, __ve_grow_stack_align@plt_hi(%s16, %s12)
355 ; PIC-NEXT: or %s1, -32, (0)1
356 ; PIC-NEXT: bsic %s10, (, %s12)
357 ; PIC-NEXT: lea %s0, 240(, %s11)
358 ; PIC-NEXT: ld1b.zx %s1, (, %s2)
359 ; PIC-NEXT: lea %s0, 31(, %s0)
360 ; PIC-NEXT: and %s2, -32, %s0
361 ; PIC-NEXT: lea %s0, 256(, %s17)
362 ; PIC-NEXT: st1b %s1, (, %s2)
363 ; PIC-NEXT: or %s11, 0, %s9
364 ; PIC-NEXT: ld %s17, 40(, %s11)
365 ; PIC-NEXT: ld %s16, 32(, %s11)
366 ; PIC-NEXT: ld %s15, 24(, %s11)
367 ; PIC-NEXT: ld %s10, 8(, %s11)
368 ; PIC-NEXT: ld %s9, (, %s11)
369 ; PIC-NEXT: b.l.t (, %s10)
370 %3 = alloca [32 x i8], align 32
371 call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3)
372 %4 = sext i32 %0 to i64
373 %5 = alloca i8, i64 %4, align 32
374 %6 = load i8, ptr %1, align 1
375 store volatile i8 %6, ptr %5, align 32
376 call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3)