diff options
author | Evan Cheng <evan.cheng@apple.com> | 2010-02-04 02:45:02 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2010-02-04 02:45:02 +0000 |
commit | 01676f9ff4b102197c5a7a846072a812da6186b5 (patch) | |
tree | b9546f3045d28ef821a1b2021dd88e204104c5fb /llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | |
parent | 9946b5109c4073869f809a241f7b90bc25edb358 (diff) | |
download | bcm5719-llvm-01676f9ff4b102197c5a7a846072a812da6186b5.tar.gz bcm5719-llvm-01676f9ff4b102197c5a7a846072a812da6186b5.zip |
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).
llvm-svn: 95282
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 3a25714f07c..201e899bd6a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4213,12 +4213,6 @@ isInTailCallPosition(CallSite CS, Attributes CalleeRetAttr, // 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 @@ isInTailCallPosition(CallSite CS, Attributes CalleeRetAttr, 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))) { |