1 ; RUN: llc < %s -relocation-model=static -O1 -disable-ppc-sco=false -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s -check-prefix=CHECK-SCO
2 ; RUN: llc < %s -relocation-model=static -O1 -disable-ppc-sco=false -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 | FileCheck %s -check-prefix=CHECK-SCO
3 ; RUN: llc < %s -relocation-model=static -O1 -disable-ppc-sco=false -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 | FileCheck %s -check-prefix=CHECK-SCO
4 ; RUN: llc < %s -relocation-model=static -O1 -disable-ppc-sco=false -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 -code-model=small | FileCheck %s -check-prefix=SCM
6 ; No combination of "powerpc64le-unknown-linux-gnu" + "CHECK-SCO", because
7 ; only Power8 (and later) fully support LE.
9 %S_56 = type { [13 x i32], i32 }
10 %S_64 = type { [15 x i32], i32 }
11 %S_32 = type { [7 x i32], i32 }
13 ; Function Attrs: noinline nounwind
14 define dso_local void @callee_56_copy([7 x i64] %a, ptr %b) #0 { ret void }
15 define dso_local void @callee_64_copy([8 x i64] %a, ptr %b) #0 { ret void }
17 ; Function Attrs: nounwind
18 define dso_local void @caller_56_reorder_copy(ptr %b, [7 x i64] %a) #1 {
19 tail call void @callee_56_copy([7 x i64] %a, ptr %b)
22 ; CHECK-SCO-LABEL: caller_56_reorder_copy:
23 ; CHECK-SCO-NOT: stdu 1
24 ; CHECK-SCO: TC_RETURNd8 callee_56_copy
27 define dso_local void @caller_64_reorder_copy(ptr %b, [8 x i64] %a) #1 {
28 tail call void @callee_64_copy([8 x i64] %a, ptr %b)
31 ; CHECK-SCO-LABEL: caller_64_reorder_copy:
32 ; CHECK-SCO: bl callee_64_copy
35 define dso_local void @callee_64_64_copy([8 x i64] %a, [8 x i64] %b) #0 { ret void }
36 define dso_local void @caller_64_64_copy([8 x i64] %a, [8 x i64] %b) #1 {
37 tail call void @callee_64_64_copy([8 x i64] %a, [8 x i64] %b)
40 ; CHECK-SCO-LABEL: caller_64_64_copy:
41 ; CHECK-SCO: b callee_64_64_copy
44 define internal fastcc void @callee_64_64_copy_fastcc([8 x i64] %a, [8 x i64] %b) #0 { ret void }
45 define dso_local void @caller_64_64_copy_ccc([8 x i64] %a, [8 x i64] %b) #1 {
46 tail call fastcc void @callee_64_64_copy_fastcc([8 x i64] %a, [8 x i64] %b)
48 ; If caller and callee use different calling convensions, we cannot apply TCO.
49 ; CHECK-SCO-LABEL: caller_64_64_copy_ccc:
50 ; CHECK-SCO: bl callee_64_64_copy_fastcc
53 define dso_local void @caller_64_64_reorder_copy([8 x i64] %a, [8 x i64] %b) #1 {
54 tail call void @callee_64_64_copy([8 x i64] %b, [8 x i64] %a)
57 ; CHECK-SCO-LABEL: caller_64_64_reorder_copy:
58 ; CHECK-SCO: bl callee_64_64_copy
61 define dso_local void @caller_64_64_undef_copy([8 x i64] %a, [8 x i64] %b) #1 {
62 tail call void @callee_64_64_copy([8 x i64] %a, [8 x i64] undef)
65 ; CHECK-SCO-LABEL: caller_64_64_undef_copy:
66 ; CHECK-SCO: b callee_64_64_copy
69 define dso_local void @arg8_callee(
70 float %a, i32 signext %b, float %c, ptr %d,
71 i8 zeroext %e, float %f, ptr %g, i32 signext %h)
76 define dso_local void @arg8_caller(float %a, i32 signext %b, i8 zeroext %c, ptr %d) {
78 tail call void @arg8_callee(float undef, i32 signext undef, float undef,
79 ptr %d, i8 zeroext undef, float undef,
80 ptr undef, i32 signext undef)
83 ; CHECK-SCO-LABEL: arg8_caller:
84 ; CHECK-SCO: b arg8_callee
89 ; Function Attrs: noinline nounwind
90 define dso_local void @callee_sret_56(ptr noalias sret(%S_56) %agg.result) #0 { ret void }
91 define dso_local void @callee_sret_32(ptr noalias sret(%S_32) %agg.result) #0 { ret void }
93 ; Function Attrs: nounwind
94 define dso_local void @caller_do_something_sret_32(ptr noalias sret(%S_32) %agg.result) #1 {
95 %1 = alloca %S_56, align 4
96 call void @callee_sret_56(ptr nonnull sret(%S_56) %1)
97 tail call void @callee_sret_32(ptr sret(%S_32) %agg.result)
100 ; CHECK-SCO-LABEL: caller_do_something_sret_32:
102 ; CHECK-SCO: bl callee_sret_56
104 ; CHECK-SCO: TC_RETURNd8 callee_sret_32
107 define dso_local void @caller_local_sret_32(ptr %a) #1 {
108 %tmp = alloca %S_32, align 4
109 tail call void @callee_sret_32(ptr nonnull sret(%S_32) %tmp)
112 ; CHECK-SCO-LABEL: caller_local_sret_32:
113 ; CHECK-SCO: bl callee_sret_32
116 attributes #0 = { noinline nounwind }
117 attributes #1 = { nounwind }
119 define dso_local void @f128_callee(ptr %ptr, ppc_fp128 %a, ppc_fp128 %b) { ret void }
120 define dso_local void @f128_caller(ptr %ptr, ppc_fp128 %a, ppc_fp128 %b) {
121 tail call void @f128_callee(ptr %ptr, ppc_fp128 %a, ppc_fp128 %b)
124 ; CHECK-SCO-LABEL: f128_caller:
125 ; CHECK-SCO: b f128_callee
129 %class.T = type { [2 x i8] }
131 define weak_odr hidden void @wo_hcallee(ptr %this, ptr %c) { ret void }
132 define dso_local void @wo_hcaller(ptr %this, ptr %c) {
133 tail call void @wo_hcallee(ptr %this, ptr %c)
136 ; CHECK-SCO-LABEL: wo_hcaller:
137 ; CHECK-SCO: bl wo_hcallee
139 ; SCM-LABEL: wo_hcaller:
143 define weak_odr protected void @wo_pcallee(ptr %this, ptr %c) { ret void }
144 define dso_local void @wo_pcaller(ptr %this, ptr %c) {
145 tail call void @wo_pcallee(ptr %this, ptr %c)
148 ; CHECK-SCO-LABEL: wo_pcaller:
149 ; CHECK-SCO: bl wo_pcallee
151 ; SCM-LABEL: wo_pcaller:
155 define weak_odr void @wo_callee(ptr %this, ptr %c) { ret void }
156 define dso_local void @wo_caller(ptr %this, ptr %c) {
157 tail call void @wo_callee(ptr %this, ptr %c)
160 ; CHECK-SCO-LABEL: wo_caller:
161 ; CHECK-SCO: bl wo_callee
163 ; SCM-LABEL: wo_caller:
167 define weak protected void @w_pcallee(ptr %ptr) { ret void }
168 define dso_local void @w_pcaller(ptr %ptr) {
169 tail call void @w_pcallee(ptr %ptr)
172 ; CHECK-SCO-LABEL: w_pcaller:
173 ; CHECK-SCO: bl w_pcallee
175 ; SCM-LABEL: w_pcaller:
179 define weak hidden void @w_hcallee(ptr %ptr) { ret void }
180 define dso_local void @w_hcaller(ptr %ptr) {
181 tail call void @w_hcallee(ptr %ptr)
184 ; CHECK-SCO-LABEL: w_hcaller:
185 ; CHECK-SCO: bl w_hcallee
187 ; SCM-LABEL: w_hcaller:
191 define weak void @w_callee(ptr %ptr) { ret void }
192 define dso_local void @w_caller(ptr %ptr) {
193 tail call void @w_callee(ptr %ptr)
196 ; CHECK-SCO-LABEL: w_caller:
197 ; CHECK-SCO: bl w_callee
199 ; SCM-LABEL: w_caller:
203 %struct.byvalTest = type { [8 x i8] }
204 @byval = common global %struct.byvalTest zeroinitializer
206 define dso_local void @byval_callee(ptr byval(%struct.byvalTest) %ptr) { ret void }
207 define dso_local void @byval_caller() {
208 tail call void @byval_callee(ptr byval(%struct.byvalTest) @byval)
211 ; CHECK-SCO-LABEL: bl byval_callee
212 ; CHECK-SCO: bl byval_callee