forked from OSchip/llvm-project
Avoid sibcall optimization if either caller or callee is using sret semantics.
llvm-svn: 98561
This commit is contained in:
parent
e01bec9791
commit
ae5edee6c8
|
|
@ -1524,7 +1524,6 @@ X86TargetLowering::LowerFormalArguments(SDValue Chain,
|
||||||
DebugLoc dl,
|
DebugLoc dl,
|
||||||
SelectionDAG &DAG,
|
SelectionDAG &DAG,
|
||||||
SmallVectorImpl<SDValue> &InVals) {
|
SmallVectorImpl<SDValue> &InVals) {
|
||||||
|
|
||||||
MachineFunction &MF = DAG.getMachineFunction();
|
MachineFunction &MF = DAG.getMachineFunction();
|
||||||
X86MachineFunctionInfo *FuncInfo = MF.getInfo<X86MachineFunctionInfo>();
|
X86MachineFunctionInfo *FuncInfo = MF.getInfo<X86MachineFunctionInfo>();
|
||||||
|
|
||||||
|
|
@ -1826,7 +1825,8 @@ X86TargetLowering::LowerCall(SDValue Chain, SDValue Callee,
|
||||||
|
|
||||||
if (isTailCall) {
|
if (isTailCall) {
|
||||||
// Check if it's really possible to do a tail call.
|
// Check if it's really possible to do a tail call.
|
||||||
isTailCall = IsEligibleForTailCallOptimization(Callee, CallConv, isVarArg,
|
isTailCall = IsEligibleForTailCallOptimization(Callee, CallConv,
|
||||||
|
isVarArg, IsStructRet, MF.getFunction()->hasStructRetAttr(),
|
||||||
Outs, Ins, DAG);
|
Outs, Ins, DAG);
|
||||||
|
|
||||||
// Sibcalls are automatically detected tailcalls which do not require
|
// Sibcalls are automatically detected tailcalls which do not require
|
||||||
|
|
@ -2324,6 +2324,8 @@ bool
|
||||||
X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
|
X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
|
||||||
CallingConv::ID CalleeCC,
|
CallingConv::ID CalleeCC,
|
||||||
bool isVarArg,
|
bool isVarArg,
|
||||||
|
bool isCalleeStructRet,
|
||||||
|
bool isCallerStructRet,
|
||||||
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
||||||
const SmallVectorImpl<ISD::InputArg> &Ins,
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
||||||
SelectionDAG& DAG) const {
|
SelectionDAG& DAG) const {
|
||||||
|
|
@ -2343,10 +2345,15 @@ X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
|
||||||
// Look for obvious safe cases to perform tail call optimization that does not
|
// Look for obvious safe cases to perform tail call optimization that does not
|
||||||
// requite ABI changes. This is what gcc calls sibcall.
|
// requite ABI changes. This is what gcc calls sibcall.
|
||||||
|
|
||||||
// Do not tail call optimize vararg calls for now.
|
// Do not sibcall optimize vararg calls for now.
|
||||||
if (isVarArg)
|
if (isVarArg)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Also avoid sibcall optimization if either caller or callee uses struct
|
||||||
|
// return semantics.
|
||||||
|
if (isCalleeStructRet || isCallerStructRet)
|
||||||
|
return false;
|
||||||
|
|
||||||
// If the callee takes no arguments then go on to check the results of the
|
// If the callee takes no arguments then go on to check the results of the
|
||||||
// call.
|
// call.
|
||||||
if (!Outs.empty()) {
|
if (!Outs.empty()) {
|
||||||
|
|
|
||||||
|
|
@ -630,6 +630,8 @@ namespace llvm {
|
||||||
bool IsEligibleForTailCallOptimization(SDValue Callee,
|
bool IsEligibleForTailCallOptimization(SDValue Callee,
|
||||||
CallingConv::ID CalleeCC,
|
CallingConv::ID CalleeCC,
|
||||||
bool isVarArg,
|
bool isVarArg,
|
||||||
|
bool isCalleeStructRet,
|
||||||
|
bool isCallerStructRet,
|
||||||
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
||||||
const SmallVectorImpl<ISD::InputArg> &Ins,
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
||||||
SelectionDAG& DAG) const;
|
SelectionDAG& DAG) const;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue