aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2010-02-04 02:45:02 +0000
committerEvan Cheng <evan.cheng@apple.com>2010-02-04 02:45:02 +0000
commit446bc10085482aba8cde79d22e10c1fe90ac54b9 (patch)
tree6a3c585b78e0eecd0e7db955f825b2beb160c532 /lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
parent32efba698df6aa35335eeb44d89288352d04746d (diff)
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).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95282 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 3a25714f07..201e899bd6 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/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))) {