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 | c75cbe6473d7be8c6eab57c1652394fbc57d9dd3 (patch) | |
| tree | 070911b8bae70a0d9f39879671cbd961cd647ecb /llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp | |
| parent | acb1e7478f470e55851250348bdff2ae5e5330ba (diff) | |
| download | bcm5719-llvm-c75cbe6473d7be8c6eab57c1652394fbc57d9dd3.tar.gz bcm5719-llvm-c75cbe6473d7be8c6eab57c1652394fbc57d9dd3.zip | |
Prevent tailcallelim from breaking "recursive" calls to builtins.
llvm-svn: 41804
Diffstat (limited to 'llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp index 497b81fecde..7eb47ddaa4f 100644 --- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/llvm/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. |

