mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-12 07:21:56 +00:00
If call result is in ST0 and it is not being passed to the caller's
caller, then it is not safe to optimize the call into a sibcall since the call result has to be popped off the x87 stack. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99032 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
873decbb37
commit
f5b9d6cc82
@ -2310,6 +2310,28 @@ X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
|
||||
if (isCalleeStructRet || isCallerStructRet)
|
||||
return false;
|
||||
|
||||
// If the call result is in ST0 / ST1, it needs to be popped off the x87 stack.
|
||||
// Therefore if it's not used by the call it is not safe to optimize this into
|
||||
// a sibcall.
|
||||
bool Unused = false;
|
||||
for (unsigned i = 0, e = Ins.size(); i != e; ++i) {
|
||||
if (!Ins[i].Used) {
|
||||
Unused = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Unused) {
|
||||
SmallVector<CCValAssign, 16> RVLocs;
|
||||
CCState CCInfo(CalleeCC, false, getTargetMachine(),
|
||||
RVLocs, *DAG.getContext());
|
||||
CCInfo.AnalyzeCallResult(Ins, RetCC_X86);
|
||||
for (unsigned i = 0; i != RVLocs.size(); ++i) {
|
||||
CCValAssign &VA = RVLocs[i];
|
||||
if (VA.getLocReg() == X86::ST0 || VA.getLocReg() == X86::ST1)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If the callee takes no arguments then go on to check the results of the
|
||||
// call.
|
||||
if (!Outs.empty()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user