llvm.org GIT mirror llvm / 8d9455d
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 Chris Lattner 12 years ago
2 changed file(s) with 19 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
300300 Function *F = BB->getParent();
301301
302302 if (&BB->front() == Ret) // Make sure there is something before the ret...
303 return false;
304
305 // If the return is in the entry block, then making this transformation would
306 // turn infinite recursion into an infinite loop. This transformation is ok
307 // in theory, but breaks some code like:
308 // double fabs(double f) { return __builtin_fabs(f); } // a 'fabs' call
309 // disable this xform in this case, because the code generator will lower the
310 // call to fabs into inline code.
311 if (BB == &F->getEntryBlock())
303312 return false;
304313
305314 // Scan backwards from the return, checking to see if there is a tail call in
0 ; RUN: llvm-as < %s | opt -tailcallelim | grep call
1 ; Don't turn this into an infinite loop, this is probably the implementation
2 ; of fabs and we expect the codegen to lower fabs.
3
4 define double @fabs(double %f) {
5 entry:
6 %tmp2 = call double @fabs( double %f ) ; [#uses=1]
7 ret double %tmp2
8 }
9