[llvm-branch-commits] [llvm-branch] r99293 - in /llvm/branches/release_27: ./ lib/Target/X86/X86ISelLowering.cpp

Tanya Lattner tonic at nondot.org
Tue Mar 23 10:16:35 PDT 2010


Author: tbrethou
Date: Tue Mar 23 12:16:35 2010
New Revision: 99293

URL: http://llvm.org/viewvc/llvm-project?rev=99293&view=rev
Log:
Merge 99032 from mainline.
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.

Modified:
    llvm/branches/release_27/   (props changed)
    llvm/branches/release_27/lib/Target/X86/X86ISelLowering.cpp

Propchange: llvm/branches/release_27/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 23 12:16:35 2010
@@ -1 +1 @@
-/llvm/trunk:97965,97974,97980,98171,98193,98203,98205,98212,98416,98561,98845,98977
+/llvm/trunk:97965,97974,97980,98171,98193,98203,98205,98212,98416,98561,98845,98977,99032

Modified: llvm/branches/release_27/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_27/lib/Target/X86/X86ISelLowering.cpp?rev=99293&r1=99292&r2=99293&view=diff
==============================================================================
--- llvm/branches/release_27/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/branches/release_27/lib/Target/X86/X86ISelLowering.cpp Tue Mar 23 12:16:35 2010
@@ -2327,6 +2327,28 @@
   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()) {





More information about the llvm-branch-commits mailing list