diff options
author | Evan Cheng <evan.cheng@apple.com> | 2010-03-20 02:58:15 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2010-03-20 02:58:15 +0000 |
commit | 3f6f769c4fc0bd43b1afbb1f3ec55519d7cb1423 (patch) | |
tree | 1aa51cc69b49cfd5df3f7db949f6999bdce23044 | |
parent | 5ea5fab22b200d4cdc360a2aef052e218c4ad4ed (diff) | |
download | bcm5719-llvm-3f6f769c4fc0bd43b1afbb1f3ec55519d7cb1423.tar.gz bcm5719-llvm-3f6f769c4fc0bd43b1afbb1f3ec55519d7cb1423.zip |
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.
llvm-svn: 99032
-rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 7d2140bf4d9..704f9c65a59 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -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()) { |