diff options
author | Chris Lattner <sabre@nondot.org> | 2007-09-10 20:58:55 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-09-10 20:58:55 +0000 |
commit | 8d9455d4e4f63c368f17b74a36b472fc61685310 (patch) | |
tree | cff716eae06b3bfc787df1093f8c486c7ffb28d7 /lib/Transforms | |
parent | b0869ed44d477b63c304eee762abb49d73b4fd68 (diff) |
Prevent tailcallelim from breaking "recursive" calls to builtins.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41804 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/TailRecursionElimination.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp index 497b81fecd..7eb47ddaa4 100644 --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -302,6 +302,15 @@ bool TailCallElim::ProcessReturningBlock(ReturnInst *Ret, BasicBlock *&OldEntry, if (&BB->front() == Ret) // Make sure there is something before the ret... return false; + + // If the return is in the entry block, then making this transformation would + // turn infinite recursion into an infinite loop. This transformation is ok + // in theory, but breaks some code like: + // double fabs(double f) { return __builtin_fabs(f); } // a 'fabs' call + // disable this xform in this case, because the code generator will lower the + // call to fabs into inline code. + if (BB == &F->getEntryBlock()) + return false; // Scan backwards from the return, checking to see if there is a tail call in // this block. If so, set CI to it. |