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 5 6; No combination of "powerpc64le-unknown-linux-gnu" + "CHECK-SCO", because 7; only Power8 (and later) fully support LE. 8 9%S_56 = type { [13 x i32], i32 } 10%S_64 = type { [15 x i32], i32 } 11%S_32 = type { [7 x i32], i32 } 12 13; Function Attrs: noinline nounwind 14define void @callee_56_copy([7 x i64] %a, %S_56* %b) #0 { ret void } 15define void @callee_64_copy([8 x i64] %a, %S_64* %b) #0 { ret void } 16 17; Function Attrs: nounwind 18define 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) 20 ret void 21 22; CHECK-SCO-LABEL: caller_56_reorder_copy: 23; CHECK-SCO-NOT: stdu 1 24; CHECK-SCO: TC_RETURNd8 callee_56_copy 25} 26 27define 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) 29 ret void 30 31; CHECK-SCO-LABEL: caller_64_reorder_copy: 32; CHECK-SCO: bl callee_64_copy 33} 34 35define void @callee_64_64_copy([8 x i64] %a, [8 x i64] %b) #0 { ret void } 36define 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) 38 ret void 39 40; CHECK-SCO-LABEL: caller_64_64_copy: 41; CHECK-SCO: b callee_64_64_copy 42} 43 44define internal fastcc void @callee_64_64_copy_fastcc([8 x i64] %a, [8 x i64] %b) #0 { ret void } 45define 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) 47 ret void 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 51} 52 53define 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) 55 ret void 56 57; CHECK-SCO-LABEL: caller_64_64_reorder_copy: 58; CHECK-SCO: bl callee_64_64_copy 59} 60 61define 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) 63 ret void 64 65; CHECK-SCO-LABEL: caller_64_64_undef_copy: 66; CHECK-SCO: b callee_64_64_copy 67} 68 69define void @arg8_callee( 70 float %a, i32 signext %b, float %c, i32* %d, 71 i8 zeroext %e, float %f, i32* %g, i32 signext %h) 72{ 73 ret void 74} 75 76define void @arg8_caller(float %a, i32 signext %b, i8 zeroext %c, i32* %d) { 77entry: 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) 81 ret void 82 83; CHECK-SCO-LABEL: arg8_caller: 84; CHECK-SCO: b arg8_callee 85} 86 87; Struct return test 88 89; Function Attrs: noinline nounwind 90define void @callee_sret_56(%S_56* noalias sret(%S_56) %agg.result) #0 { ret void } 91define void @callee_sret_32(%S_32* noalias sret(%S_32) %agg.result) #0 { ret void } 92 93; Function Attrs: nounwind 94define 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) 99 ret void 100 101; CHECK-SCO-LABEL: caller_do_something_sret_32: 102; CHECK-SCO: stdu 1 103; CHECK-SCO: bl callee_sret_56 104; CHECK-SCO: addi 1 105; CHECK-SCO: TC_RETURNd8 callee_sret_32 106} 107 108define 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) 111 ret void 112 113; CHECK-SCO-LABEL: caller_local_sret_32: 114; CHECK-SCO: bl callee_sret_32 115} 116 117attributes #0 = { noinline nounwind } 118attributes #1 = { nounwind } 119 120define void @f128_callee(i32* %ptr, ppc_fp128 %a, ppc_fp128 %b) { ret void } 121define 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) 123 ret void 124 125; CHECK-SCO-LABEL: f128_caller: 126; CHECK-SCO: b f128_callee 127} 128 129; weak linkage test 130%class.T = type { [2 x i8] } 131 132define weak_odr hidden void @wo_hcallee(%class.T* %this, i8* %c) { ret void } 133define void @wo_hcaller(%class.T* %this, i8* %c) { 134 tail call void @wo_hcallee(%class.T* %this, i8* %c) 135 ret void 136 137; CHECK-SCO-LABEL: wo_hcaller: 138; CHECK-SCO: bl wo_hcallee 139 140; SCM-LABEL: wo_hcaller: 141; SCM: bl wo_hcallee 142} 143 144define weak_odr protected void @wo_pcallee(%class.T* %this, i8* %c) { ret void } 145define void @wo_pcaller(%class.T* %this, i8* %c) { 146 tail call void @wo_pcallee(%class.T* %this, i8* %c) 147 ret void 148 149; CHECK-SCO-LABEL: wo_pcaller: 150; CHECK-SCO: bl wo_pcallee 151 152; SCM-LABEL: wo_pcaller: 153; SCM: bl wo_pcallee 154} 155 156define weak_odr void @wo_callee(%class.T* %this, i8* %c) { ret void } 157define void @wo_caller(%class.T* %this, i8* %c) { 158 tail call void @wo_callee(%class.T* %this, i8* %c) 159 ret void 160 161; CHECK-SCO-LABEL: wo_caller: 162; CHECK-SCO: bl wo_callee 163 164; SCM-LABEL: wo_caller: 165; SCM: bl wo_callee 166} 167 168define weak protected void @w_pcallee(i8* %ptr) { ret void } 169define void @w_pcaller(i8* %ptr) { 170 tail call void @w_pcallee(i8* %ptr) 171 ret void 172 173; CHECK-SCO-LABEL: w_pcaller: 174; CHECK-SCO: bl w_pcallee 175 176; SCM-LABEL: w_pcaller: 177; SCM: bl w_pcallee 178} 179 180define weak hidden void @w_hcallee(i8* %ptr) { ret void } 181define void @w_hcaller(i8* %ptr) { 182 tail call void @w_hcallee(i8* %ptr) 183 ret void 184 185; CHECK-SCO-LABEL: w_hcaller: 186; CHECK-SCO: bl w_hcallee 187 188; SCM-LABEL: w_hcaller: 189; SCM: bl w_hcallee 190} 191 192define weak void @w_callee(i8* %ptr) { ret void } 193define void @w_caller(i8* %ptr) { 194 tail call void @w_callee(i8* %ptr) 195 ret void 196 197; CHECK-SCO-LABEL: w_caller: 198; CHECK-SCO: bl w_callee 199 200; SCM-LABEL: w_caller: 201; SCM: bl w_callee 202} 203 204%struct.byvalTest = type { [8 x i8] } 205@byval = common global %struct.byvalTest zeroinitializer 206 207define void @byval_callee(%struct.byvalTest* byval(%struct.byvalTest) %ptr) { ret void } 208define void @byval_caller() { 209 tail call void @byval_callee(%struct.byvalTest* byval(%struct.byvalTest) @byval) 210 ret void 211 212; CHECK-SCO-LABEL: bl byval_callee 213; CHECK-SCO: bl byval_callee 214} 215