1 ; RUN: llc -verify-machineinstrs < %s -mtriple=arm64-none-linux-gnu -tailcallopt | FileCheck --check-prefix=CHECK-ARM64 %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:
11 ; CHECK-ARM64-LABEL: caller_to0_from0:
12 ; CHECK-ARM64-NEXT: // BB
14 tail call fastcc void @callee_stack0()
17 ; CHECK-NEXT: b callee_stack0
19 ; CHECK-ARM64-NEXT: b callee_stack0
22 define fastcc void @caller_to0_from8([8 x i32], i64) {
23 ; CHECK-LABEL: caller_to0_from8:
25 ; CHECK-ARM64-LABEL: caller_to0_from8:
27 tail call fastcc void @callee_stack0()
30 ; CHECK: add sp, sp, #16
31 ; CHECK-NEXT: b callee_stack0
33 ; CHECK-ARM64: add sp, sp, #16
34 ; CHECK-ARM64-NEXT: b callee_stack0
37 define fastcc void @caller_to8_from0() {
38 ; CHECK-LABEL: caller_to8_from0:
39 ; CHECK: sub sp, sp, #32
41 ; CHECK-ARM64-LABEL: caller_to8_from0:
42 ; CHECK-ARM64: sub sp, sp, #32
44 ; Key point is that the "42" should go #16 below incoming stack
45 ; pointer (we didn't have arg space to reuse).
46 tail call fastcc void @callee_stack8([8 x i32] undef, i64 42)
49 ; CHECK: str {{x[0-9]+}}, [sp, #16]
50 ; CHECK-NEXT: add sp, sp, #16
51 ; CHECK-NEXT: b callee_stack8
53 ; CHECK-ARM64: str {{x[0-9]+}}, [sp, #16]!
54 ; CHECK-ARM64-NEXT: b callee_stack8
57 define fastcc void @caller_to8_from8([8 x i32], i64 %a) {
58 ; CHECK-LABEL: caller_to8_from8:
59 ; CHECK: sub sp, sp, #16
61 ; CHECK-ARM64-LABEL: caller_to8_from8:
62 ; CHECK-ARM64: sub sp, sp, #16
64 ; Key point is that the "%a" should go where at SP on entry.
65 tail call fastcc void @callee_stack8([8 x i32] undef, i64 42)
68 ; CHECK: str {{x[0-9]+}}, [sp, #16]
69 ; CHECK-NEXT: add sp, sp, #16
70 ; CHECK-NEXT: b callee_stack8
72 ; CHECK-ARM64: str {{x[0-9]+}}, [sp, #16]!
73 ; CHECK-ARM64-NEXT: b callee_stack8
76 define fastcc void @caller_to16_from8([8 x i32], i64 %a) {
77 ; CHECK-LABEL: caller_to16_from8:
78 ; CHECK: sub sp, sp, #16
80 ; CHECK-ARM64-LABEL: caller_to16_from8:
81 ; CHECK-ARM64: sub sp, sp, #16
83 ; Important point is that the call reuses the "dead" argument space
84 ; above %a on the stack. If it tries to go below incoming-SP then the
85 ; callee will not deallocate the space, even in fastcc.
86 tail call fastcc void @callee_stack16([8 x i32] undef, i64 42, i64 2)
88 ; CHECK: str {{x[0-9]+}}, [sp, #24]
89 ; CHECK: str {{x[0-9]+}}, [sp, #16]
90 ; CHECK-NEXT: add sp, sp, #16
91 ; CHECK-NEXT: b callee_stack16
93 ; CHECK-ARM64: stp {{x[0-9]+}}, {{x[0-9]+}}, [sp, #16]
94 ; CHECK-ARM64-NEXT: add sp, sp, #16
95 ; CHECK-ARM64-NEXT: b callee_stack16
100 define fastcc void @caller_to8_from24([8 x i32], i64 %a, i64 %b, i64 %c) {
101 ; CHECK-LABEL: caller_to8_from24:
102 ; CHECK: sub sp, sp, #16
104 ; CHECK-ARM64-LABEL: caller_to8_from24:
105 ; CHECK-ARM64: sub sp, sp, #16
107 ; Key point is that the "%a" should go where at #16 above SP on entry.
108 tail call fastcc void @callee_stack8([8 x i32] undef, i64 42)
111 ; CHECK: str {{x[0-9]+}}, [sp, #32]
112 ; CHECK-NEXT: add sp, sp, #32
113 ; CHECK-NEXT: b callee_stack8
115 ; CHECK-ARM64: str {{x[0-9]+}}, [sp, #32]!
116 ; CHECK-ARM64-NEXT: b callee_stack8
120 define fastcc void @caller_to16_from16([8 x i32], i64 %a, i64 %b) {
121 ; CHECK-LABEL: caller_to16_from16:
122 ; CHECK: sub sp, sp, #16
124 ; CHECK-ARM64-LABEL: caller_to16_from16:
125 ; CHECK-ARM64: sub sp, sp, #16
127 ; Here we want to make sure that both loads happen before the stores:
128 ; otherwise either %a or %b will be wrongly clobbered.
129 tail call fastcc void @callee_stack16([8 x i32] undef, i64 %b, i64 %a)
137 ; CHECK-NEXT: add sp, sp, #16
138 ; CHECK-NEXT: b callee_stack16
140 ; CHECK-ARM64: ldp {{x[0-9]+}}, {{x[0-9]+}}, [sp, #16]
141 ; CHECK-ARM64: stp {{x[0-9]+}}, {{x[0-9]+}}, [sp, #16]
142 ; CHECK-ARM64-NEXT: add sp, sp, #16
143 ; CHECK-ARM64-NEXT: b callee_stack16