1 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -tailcallopt | FileCheck %s
3 declare fastcc void @callee_stack0()
4 declare fastcc void @callee_stack8([8 x i32], i64)
5 declare fastcc void @callee_stack16([8 x i32], i64, i64)
7 define fastcc void @caller_to0_from0() nounwind {
8 ; CHECK-LABEL: caller_to0_from0:
10 tail call fastcc void @callee_stack0()
12 ; CHECK-NEXT: b callee_stack0
15 define fastcc void @caller_to0_from8([8 x i32], i64) {
16 ; CHECK-LABEL: caller_to0_from8:
18 tail call fastcc void @callee_stack0()
20 ; CHECK: add sp, sp, #16
21 ; CHECK-NEXT: b callee_stack0
24 define fastcc void @caller_to8_from0() {
25 ; CHECK-LABEL: caller_to8_from0:
26 ; CHECK: sub sp, sp, #32
28 ; Key point is that the "42" should go #16 below incoming stack
29 ; pointer (we didn't have arg space to reuse).
30 tail call fastcc void @callee_stack8([8 x i32] undef, i64 42)
32 ; CHECK: str {{x[0-9]+}}, [sp, #16]
33 ; CHECK-NEXT: add sp, sp, #16
34 ; CHECK-NEXT: b callee_stack8
37 define fastcc void @caller_to8_from8([8 x i32], i64 %a) {
38 ; CHECK-LABEL: caller_to8_from8:
39 ; CHECK: sub sp, sp, #16
41 ; Key point is that the "%a" should go where at SP on entry.
42 tail call fastcc void @callee_stack8([8 x i32] undef, i64 42)
44 ; CHECK: str {{x[0-9]+}}, [sp, #16]
45 ; CHECK-NEXT: add sp, sp, #16
46 ; CHECK-NEXT: b callee_stack8
49 define fastcc void @caller_to16_from8([8 x i32], i64 %a) {
50 ; CHECK-LABEL: caller_to16_from8:
51 ; CHECK: sub sp, sp, #16
53 ; Important point is that the call reuses the "dead" argument space
54 ; above %a on the stack. If it tries to go below incoming-SP then the
55 ; callee will not deallocate the space, even in fastcc.
56 tail call fastcc void @callee_stack16([8 x i32] undef, i64 42, i64 2)
57 ; CHECK: str {{x[0-9]+}}, [sp, #24]
58 ; CHECK: str {{x[0-9]+}}, [sp, #16]
59 ; CHECK: add sp, sp, #16
60 ; CHECK: b callee_stack16
65 define fastcc void @caller_to8_from24([8 x i32], i64 %a, i64 %b, i64 %c) {
66 ; CHECK-LABEL: caller_to8_from24:
67 ; CHECK: sub sp, sp, #16
69 ; Key point is that the "%a" should go where at #16 above SP on entry.
70 tail call fastcc void @callee_stack8([8 x i32] undef, i64 42)
72 ; CHECK: str {{x[0-9]+}}, [sp, #32]
73 ; CHECK-NEXT: add sp, sp, #32
74 ; CHECK-NEXT: b callee_stack8
78 define fastcc void @caller_to16_from16([8 x i32], i64 %a, i64 %b) {
79 ; CHECK-LABEL: caller_to16_from16:
80 ; CHECK: sub sp, sp, #16
82 ; Here we want to make sure that both loads happen before the stores:
83 ; otherwise either %a or %b will be wrongly clobbered.
84 tail call fastcc void @callee_stack16([8 x i32] undef, i64 %b, i64 %a)
92 ; CHECK: add sp, sp, #16
93 ; CHECK: b callee_stack16