1 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -frame-pointer=all -tailcallopt | FileCheck %s -check-prefix CHECK-TAIL
2 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -frame-pointer=all | FileCheck %s
3 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -frame-pointer=all -tailcallopt -aarch64-redzone | FileCheck %s -check-prefix CHECK-TAIL-RZ
5 ; Without tailcallopt fastcc still means the caller cleans up the
6 ; stack, so try to make sure this is respected.
8 define fastcc void @func_stack0() {
9 ; CHECK-LABEL: func_stack0:
10 ; CHECK: sub sp, sp, #48
11 ; CHECK: add x29, sp, #32
12 ; CHECK: str w{{[0-9]+}}, [sp]
14 ; CHECK-TAIL-LABEL: func_stack0:
15 ; CHECK-TAIL: sub sp, sp, #48
16 ; CHECK-TAIL-NEXT: stp x29, x30, [sp, #32]
17 ; CHECK-TAIL-NEXT: add x29, sp, #32
18 ; CHECK-TAIL: str w{{[0-9]+}}, [sp]
21 call fastcc void @func_stack8([8 x i64] undef, i32 42)
22 ; CHECK: bl func_stack8
23 ; CHECK-NOT: sub sp, sp,
24 ; CHECK-NOT: [sp, #{{[-0-9]+}}]!
25 ; CHECK-NOT: [sp], #{{[-0-9]+}}
27 ; CHECK-TAIL: bl func_stack8
28 ; CHECK-TAIL: stp xzr, xzr, [sp, #-16]!
31 call fastcc void @func_stack32([8 x i64] undef, i128 0, i128 9)
32 ; CHECK: bl func_stack32
33 ; CHECK-NOT: sub sp, sp,
36 ; CHECK-TAIL: bl func_stack32
37 ; CHECK-TAIL: sub sp, sp, #32
40 call fastcc void @func_stack0()
41 ; CHECK: bl func_stack0
42 ; CHECK-NOT: sub sp, sp
45 ; CHECK-TAIL: bl func_stack0
46 ; CHECK-TAIL-NOT: sub sp, sp
49 ; CHECK: ldp x29, x30, [sp, #32]
50 ; CHECK-NEXT: add sp, sp, #48
54 ; CHECK-TAIL: ldp x29, x30, [sp, #32]
55 ; CHECK-TAIL-NEXT: add sp, sp, #48
56 ; CHECK-TAIL-NEXT: ret
59 define fastcc void @func_stack8([8 x i64], i32 %stacked) {
60 ; CHECK-LABEL: func_stack8:
61 ; CHECK: sub sp, sp, #48
62 ; CHECK: stp x29, x30, [sp, #32]
63 ; CHECK: add x29, sp, #32
64 ; CHECK: str w{{[0-9]+}}, [sp]
67 ; CHECK-TAIL-LABEL: func_stack8:
68 ; CHECK-TAIL: sub sp, sp, #48
69 ; CHECK-TAIL: stp x29, x30, [sp, #32]
70 ; CHECK-TAIL: add x29, sp, #32
71 ; CHECK-TAIL: str w{{[0-9]+}}, [sp]
74 call fastcc void @func_stack8([8 x i64] undef, i32 42)
75 ; CHECK: bl func_stack8
76 ; CHECK-NOT: sub sp, sp,
77 ; CHECK-NOT: [sp, #{{[-0-9]+}}]!
78 ; CHECK-NOT: [sp], #{{[-0-9]+}}
81 ; CHECK-TAIL: bl func_stack8
82 ; CHECK-TAIL: stp xzr, xzr, [sp, #-16]!
85 call fastcc void @func_stack32([8 x i64] undef, i128 0, i128 9)
86 ; CHECK: bl func_stack32
87 ; CHECK-NOT: sub sp, sp,
90 ; CHECK-TAIL: bl func_stack32
91 ; CHECK-TAIL: sub sp, sp, #32
94 call fastcc void @func_stack0()
95 ; CHECK: bl func_stack0
96 ; CHECK-NOT: sub sp, sp
98 ; CHECK-TAIL: bl func_stack0
99 ; CHECK-TAIL-NOT: sub sp, sp
102 ; CHECK-NEXT: ldp x29, x30, [sp, #32]
103 ; CHECK: add sp, sp, #48
107 ; CHECK-TAIL: ldp x29, x30, [sp, #32]
108 ; CHECK-TAIL-NEXT: add sp, sp, #64
109 ; CHECK-TAIL-NEXT: ret
112 define fastcc void @func_stack32([8 x i64], i128 %stacked0, i128 %stacked1) {
113 ; CHECK-LABEL: func_stack32:
114 ; CHECK: add x29, sp, #32
116 ; CHECK-TAIL-LABEL: func_stack32:
117 ; CHECK-TAIL: add x29, sp, #32
120 call fastcc void @func_stack8([8 x i64] undef, i32 42)
121 ; CHECK: bl func_stack8
122 ; CHECK-NOT: sub sp, sp,
123 ; CHECK-NOT: [sp, #{{[-0-9]+}}]!
124 ; CHECK-NOT: [sp], #{{[-0-9]+}}
126 ; CHECK-TAIL: bl func_stack8
127 ; CHECK-TAIL: stp xzr, xzr, [sp, #-16]!
130 call fastcc void @func_stack32([8 x i64] undef, i128 0, i128 9)
131 ; CHECK: bl func_stack32
132 ; CHECK-NOT: sub sp, sp,
135 ; CHECK-TAIL: bl func_stack32
136 ; CHECK-TAIL: sub sp, sp, #32
139 call fastcc void @func_stack0()
140 ; CHECK: bl func_stack0
141 ; CHECK-NOT: sub sp, sp
144 ; CHECK-TAIL: bl func_stack0
145 ; CHECK-TAIL-NOT: sub sp, sp
148 ; CHECK: ldp x29, x30, [sp, #32]
149 ; CHECK-NEXT: add sp, sp, #48
152 ; CHECK-TAIL: ldp x29, x30, [sp, #32]
153 ; CHECK-TAIL-NEXT: add sp, sp, #80
154 ; CHECK-TAIL-NEXT: ret
157 ; Check that arg stack pop is done after callee-save restore when no frame pointer is used.
158 define fastcc void @func_stack32_leaf([8 x i64], i128 %stacked0, i128 %stacked1) {
159 ; CHECK-LABEL: func_stack32_leaf:
160 ; CHECK: str x20, [sp, #-16]!
162 ; CHECK-NEXT: //NO_APP
163 ; CHECK-NEXT: ldr x20, [sp], #16
166 ; CHECK-TAIL-LABEL: func_stack32_leaf:
167 ; CHECK-TAIL: str x20, [sp, #-16]!
169 ; CHECK-TAIL-NEXT: //NO_APP
170 ; CHECK-TAIL-NEXT: ldr x20, [sp], #16
171 ; CHECK-TAIL-NEXT: add sp, sp, #32
172 ; CHECK-TAIL-NEXT: ret
174 ; CHECK-TAIL-RZ-LABEL: func_stack32_leaf:
175 ; CHECK-TAIL-RZ: str x20, [sp, #-16]!
176 ; CHECK-TAIL-RZ-NOT: sub sp, sp
178 ; CHECK-TAIL-RZ-NEXT: //NO_APP
179 ; CHECK-TAIL-RZ-NEXT: ldr x20, [sp], #16
180 ; CHECK-TAIL-RZ-NEXT: add sp, sp, #32
181 ; CHECK-TAIL-RZ-NEXT: ret
183 ; Make sure there is a callee-save register to save/restore.
184 call void asm sideeffect "nop", "~{x20}"() nounwind
188 ; Check that arg stack pop is done after callee-save restore when no frame pointer is used.
189 define fastcc void @func_stack32_leaf_local([8 x i64], i128 %stacked0, i128 %stacked1) {
190 ; CHECK-LABEL: func_stack32_leaf_local:
191 ; CHECK: sub sp, sp, #32
192 ; CHECK-NEXT: str x20, [sp, #16]
194 ; CHECK-NEXT: //NO_APP
195 ; CHECK-NEXT: ldr x20, [sp, #16]
196 ; CHECK-NEXT: add sp, sp, #32
199 ; CHECK-TAIL-LABEL: func_stack32_leaf_local:
200 ; CHECK-TAIL: sub sp, sp, #32
201 ; CHECK-TAIL-NEXT: str x20, [sp, #16]
203 ; CHECK-TAIL-NEXT: //NO_APP
204 ; CHECK-TAIL-NEXT: ldr x20, [sp, #16]
205 ; CHECK-TAIL-NEXT: add sp, sp, #64
206 ; CHECK-TAIL-NEXT: ret
208 ; CHECK-TAIL-RZ-LABEL: func_stack32_leaf_local:
209 ; CHECK-TAIL-RZ: str x20, [sp, #-16]!
210 ; CHECK-TAIL-RZ-NOT: sub sp, sp
212 ; CHECK-TAIL-RZ-NEXT: //NO_APP
213 ; CHECK-TAIL-RZ-NEXT: ldr x20, [sp], #16
214 ; CHECK-TAIL-RZ-NEXT: add sp, sp, #32
215 ; CHECK-TAIL-RZ-NEXT: ret
217 %val0 = alloca [2 x i64], align 8
219 ; Make sure there is a callee-save register to save/restore.
220 call void asm sideeffect "nop", "~{x20}"() nounwind
224 ; Check that arg stack pop is done after callee-save restore when no frame pointer is used.
225 define fastcc void @func_stack32_leaf_local_nocs([8 x i64], i128 %stacked0, i128 %stacked1) {
226 ; CHECK-LABEL: func_stack32_leaf_local_nocs:
227 ; CHECK: sub sp, sp, #16
228 ; CHECK: add sp, sp, #16
231 ; CHECK-TAIL-LABEL: func_stack32_leaf_local_nocs:
232 ; CHECK-TAIL: sub sp, sp, #16
233 ; CHECK-TAIL: add sp, sp, #48
234 ; CHECK-TAIL-NEXT: ret
236 ; CHECK-TAIL-RZ-LABEL: func_stack32_leaf_local_nocs:
237 ; CHECK-TAIL-RZ: add sp, sp, #32
238 ; CHECK-TAIL-RZ-NEXT: ret
240 %val0 = alloca [2 x i64], align 8