Index: lib/Target/PowerPC/PPCISelLowering.cpp =================================================================== --- lib/Target/PowerPC/PPCISelLowering.cpp +++ lib/Target/PowerPC/PPCISelLowering.cpp @@ -3964,11 +3964,16 @@ if (CalleeCC != CallingConv::Fast && CalleeCC != CallingConv::C) return false; - // Functions containing by val parameters are not supported. + // Caller contains any byval parameter is not supported. if (std::any_of(Ins.begin(), Ins.end(), [](const ISD::InputArg& IA) { return IA.Flags.isByVal(); })) return false; + // Callee contains any byval parameter is not supported, too. + if (std::any_of(Outs.begin(), Outs.end(), + [](const ISD::OutputArg& OA) { return OA.Flags.isByVal(); })) + return false; + // No TCO/SCO on indirect call because Caller have to restore its TOC if (!isFunctionGlobalAddress(Callee) && !isa(Callee)) Index: test/CodeGen/PowerPC/ppc64-sibcall.ll =================================================================== --- test/CodeGen/PowerPC/ppc64-sibcall.ll +++ test/CodeGen/PowerPC/ppc64-sibcall.ll @@ -189,3 +189,15 @@ ; CHECK-SCO-LABEL: w_caller: ; CHECK-SCO: bl w_callee } + +%struct.byvalTest = type { [8 x i8] } +@byval = common global %struct.byvalTest zeroinitializer + +define void @byval_callee(%struct.byvalTest* byval %ptr) { ret void } +define void @byval_caller() { + tail call void @byval_callee(%struct.byvalTest* byval @byval) + ret void + +; CHECK-SCO-LABEL: bl byval_callee +; CHECK-SCO: bl byval_callee +}