From c2e93b255e120f066ad8c16b0593b05f7e9f3d19 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 8 Feb 2010 20:34:14 +0000 Subject: In guaranteed tailcall mode, don't decline the tailcall optimization for blocks ending in "unreachable". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95565 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp') diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index cf342c793b..93ae043dbc 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4205,13 +4205,16 @@ isInTailCallPosition(CallSite CS, Attributes CalleeRetAttr, const ReturnInst *Ret = dyn_cast(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(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. -- cgit v1.2.3-18-g5258