diff options
| author | Dan Gohman <gohman@apple.com> | 2010-02-08 20:34:14 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2010-02-08 20:34:14 +0000 |
| commit | bd374da130b9f1835e666088bb9c241e2bfce74b (patch) | |
| tree | db8f0ae334b4af7d971ab9e3a13c481d2adcd162 /llvm/lib | |
| parent | 3464a5b6090a386dad3111edb7df49ca42526421 (diff) | |
| download | bcm5719-llvm-bd374da130b9f1835e666088bb9c241e2bfce74b.tar.gz bcm5719-llvm-bd374da130b9f1835e666088bb9c241e2bfce74b.zip | |
In guaranteed tailcall mode, don't decline the tailcall optimization
for blocks ending in "unreachable".
llvm-svn: 95565
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index cf342c793b9..93ae043dbc1 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4205,13 +4205,16 @@ 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. - // 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; + // The block must end in a return statement or unreachable. + // + // FIXME: Decline tailcall if it's not guaranteed and 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 && + (!GuaranteedTailCallOpt || !isa<UnreachableInst>(Term))) return false; // If I will have a chain, make sure no other instruction that will have a // chain interposes between I and the return. |

