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, %S_56* %b) #0 { ret void }
15 define dso_local void @callee_64_copy([8 x i64] %a, %S_64* %b) #0 { ret void }
17 ; Function Attrs: nounwind
18 define dso_local void @caller_56_reorder_copy(%S_56* %b, [7 x i64] %a) #1 {
19 tail call void @callee_56_copy([7 x i64] %a, %S_56* %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(%S_64* %b, [8 x i64] %a) #1 {
28 tail call void @callee_64_copy([8 x i64] %a, %S_64* %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, i32* %d,
71 i8 zeroext %e, float %f, i32* %g, i32 signext %h)
76 define dso_local void @arg8_caller(float %a, i32 signext %b, i8 zeroext %c, i32* %d) {
78 tail call void @arg8_callee(float undef, i32 signext undef, float undef,
79 i32* %d, i8 zeroext undef, float undef,
80 i32* 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(%S_56* noalias sret(%S_56) %agg.result) #0 { ret void }
91 define dso_local void @callee_sret_32(%S_32* noalias sret(%S_32) %agg.result) #0 { ret void }
93 ; Function Attrs: nounwind
94 define dso_local void @caller_do_something_sret_32(%S_32* noalias sret(%S_32) %agg.result) #1 {
95 %1 = alloca %S_56, align 4
96 %2 = bitcast %S_56* %1 to i8*
97 call void @callee_sret_56(%S_56* nonnull sret(%S_56) %1)
98 tail call void @callee_sret_32(%S_32* sret(%S_32) %agg.result)
101 ; CHECK-SCO-LABEL: caller_do_something_sret_32:
103 ; CHECK-SCO: bl callee_sret_56
105 ; CHECK-SCO: TC_RETURNd8 callee_sret_32
108 define dso_local void @caller_local_sret_32(%S_32* %a) #1 {
109 %tmp = alloca %S_32, align 4
110 tail call void @callee_sret_32(%S_32* nonnull sret(%S_32) %tmp)
113 ; CHECK-SCO-LABEL: caller_local_sret_32:
114 ; CHECK-SCO: bl callee_sret_32
117 attributes #0 = { noinline nounwind }
118 attributes #1 = { nounwind }
120 define dso_local void @f128_callee(i32* %ptr, ppc_fp128 %a, ppc_fp128 %b) { ret void }
121 define dso_local void @f128_caller(i32* %ptr, ppc_fp128 %a, ppc_fp128 %b) {
122 tail call void @f128_callee(i32* %ptr, ppc_fp128 %a, ppc_fp128 %b)
125 ; CHECK-SCO-LABEL: f128_caller:
126 ; CHECK-SCO: b f128_callee
130 %class.T = type { [2 x i8] }
132 define weak_odr hidden void @wo_hcallee(%class.T* %this, i8* %c) { ret void }
133 define dso_local void @wo_hcaller(%class.T* %this, i8* %c) {
134 tail call void @wo_hcallee(%class.T* %this, i8* %c)
137 ; CHECK-SCO-LABEL: wo_hcaller:
138 ; CHECK-SCO: bl wo_hcallee
140 ; SCM-LABEL: wo_hcaller:
144 define weak_odr protected void @wo_pcallee(%class.T* %this, i8* %c) { ret void }
145 define dso_local void @wo_pcaller(%class.T* %this, i8* %c) {
146 tail call void @wo_pcallee(%class.T* %this, i8* %c)
149 ; CHECK-SCO-LABEL: wo_pcaller:
150 ; CHECK-SCO: bl wo_pcallee
152 ; SCM-LABEL: wo_pcaller:
156 define weak_odr void @wo_callee(%class.T* %this, i8* %c) { ret void }
157 define dso_local void @wo_caller(%class.T* %this, i8* %c) {
158 tail call void @wo_callee(%class.T* %this, i8* %c)
161 ; CHECK-SCO-LABEL: wo_caller:
162 ; CHECK-SCO: bl wo_callee
164 ; SCM-LABEL: wo_caller:
168 define weak protected void @w_pcallee(i8* %ptr) { ret void }
169 define dso_local void @w_pcaller(i8* %ptr) {
170 tail call void @w_pcallee(i8* %ptr)
173 ; CHECK-SCO-LABEL: w_pcaller:
174 ; CHECK-SCO: bl w_pcallee
176 ; SCM-LABEL: w_pcaller:
180 define weak hidden void @w_hcallee(i8* %ptr) { ret void }
181 define dso_local void @w_hcaller(i8* %ptr) {
182 tail call void @w_hcallee(i8* %ptr)
185 ; CHECK-SCO-LABEL: w_hcaller:
186 ; CHECK-SCO: bl w_hcallee
188 ; SCM-LABEL: w_hcaller:
192 define weak void @w_callee(i8* %ptr) { ret void }
193 define dso_local void @w_caller(i8* %ptr) {
194 tail call void @w_callee(i8* %ptr)
197 ; CHECK-SCO-LABEL: w_caller:
198 ; CHECK-SCO: bl w_callee
200 ; SCM-LABEL: w_caller:
204 %struct.byvalTest = type { [8 x i8] }
205 @byval = common global %struct.byvalTest zeroinitializer
207 define dso_local void @byval_callee(%struct.byvalTest* byval(%struct.byvalTest) %ptr) { ret void }
208 define dso_local void @byval_caller() {
209 tail call void @byval_callee(%struct.byvalTest* byval(%struct.byvalTest) @byval)
212 ; CHECK-SCO-LABEL: bl byval_callee
213 ; CHECK-SCO: bl byval_callee