diff options
author | Evan Cheng <evan.cheng@apple.com> | 2010-02-03 03:55:59 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2010-02-03 03:55:59 +0000 |
commit | 27a41d5473041c2b6d9459ddd2299381dad9678d (patch) | |
tree | 98835a2da77aea26670acb34a89e5abc46ff2f0b /llvm/lib | |
parent | 6a6f9cc634f6e8eb29cfa1060939c4daa90afaf0 (diff) | |
download | bcm5719-llvm-27a41d5473041c2b6d9459ddd2299381dad9678d.tar.gz bcm5719-llvm-27a41d5473041c2b6d9459ddd2299381dad9678d.zip |
Revert 94937 and move the noreturn check to codegen.
llvm-svn: 95198
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp | 9 |
2 files changed, 11 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 495418d999e..3a25714f07c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4205,8 +4205,13 @@ isInTailCallPosition(CallSite CS, Attributes CalleeRetAttr, const ReturnInst *Ret = dyn_cast<ReturnInst>(Term); const Function *F = ExitBB->getParent(); - // The block must end in a return statement or an unreachable. - if (!Ret && !isa<UnreachableInst>(Term)) return false; + // The block must end in a return statement. + // FIXME: Disallow tailcall if the block ends in an unreachable for now. + // The way tailcall optimization is currently implemented means it will + // add an epilogue followed by a jump. That is not profitable. Also, if + // the callee is a special function (e.g. longjmp on x86), it can end up + // 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 diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp index 913dd73cc17..162d902cfa4 100644 --- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -184,11 +184,10 @@ bool TailCallElim::runOnFunction(Function &F) { if (!FunctionContainsEscapingAllocas) for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) - if (CallInst *CI = dyn_cast<CallInst>(I)) - if (!CI->doesNotReturn()) { - CI->setTailCall(); - MadeChange = true; - } + if (CallInst *CI = dyn_cast<CallInst>(I)) { + CI->setTailCall(); + MadeChange = true; + } return MadeChange; } |