[llvm-commits] [llvm] r95282 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Evan Cheng evan.cheng at apple.com
Wed Feb 3 18:45:02 PST 2010


Author: evancheng
Date: Wed Feb  3 20:45:02 2010
New Revision: 95282

URL: http://llvm.org/viewvc/llvm-project?rev=95282&view=rev
Log:
It's too risky to eliminate sext / zext of call results for tail call optimization even if the caller / callee attributes completely match. The callee may have been bitcast'ed (or otherwise lied about what it's doing).

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=95282&r1=95281&r2=95282&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Wed Feb  3 20:45:02 2010
@@ -4213,12 +4213,6 @@
   // causing miscompilation that has not been fully understood.
   if (!Ret) return false;
 
-  // Unless we are explicitly forcing tailcall optimization do not tailcall if
-  // the called function is bitcast'ed. The analysis may not be entirely
-  // accurate.
-  if (!PerformTailCallOpt && isa<BitCastInst>(CS.getCalledValue()))
-    return false;
-
   // If I will have a chain, make sure no other instruction that will have a
   // chain interposes between I and the return.
   if (I->mayHaveSideEffects() || I->mayReadFromMemory() ||
@@ -4246,6 +4240,10 @@
   if ((CalleeRetAttr ^ CallerRetAttr) & ~Attribute::NoAlias)
     return false;
 
+  // It's not safe to eliminate thee sign / zero extension of the return value.
+  if ((CallerRetAttr & Attribute::ZExt) || (CallerRetAttr & Attribute::SExt))
+    return false;
+
   // Otherwise, make sure the unmodified return value of I is the return value.
   for (const Instruction *U = dyn_cast<Instruction>(Ret->getOperand(0)); ;
        U = dyn_cast<Instruction>(U->getOperand(0))) {





More information about the llvm-commits mailing list