From b6ac976247fc287e58ebf922753fc4e18e560b4b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 20 Sep 2003 05:24:00 +0000 Subject: Fix a really obvious huge gaping bug, add a comment llvm-svn: 8620 --- llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp') diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp index 3945af3db75..c8ac4c5ff77 100644 --- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -50,7 +50,7 @@ bool TailCallElim::runOnFunction(Function &F) { // Loop over the function, looking for any returning blocks... for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) if (ReturnInst *Ret = dyn_cast(BB->getTerminator())) - if (Ret != BB->begin()) + if (Ret != BB->begin()) // Make sure there is something before the ret... if (CallInst *CI = dyn_cast(Ret->getPrev())) // Make sure the tail call is to the current function, and that the // return either returns void or returns the value computed by the @@ -74,6 +74,7 @@ bool TailCallElim::runOnFunction(Function &F) { for (Function::aiterator I = F.abegin(), E = F.aend(); I!=E; ++I){ PHINode *PN = new PHINode(I->getType(), I->getName()+".tr", InsertPos); + I->replaceAllUsesWith(PN); // Everyone use the PHI node now! PN->addIncoming(I, NewEntry); ArgumentPHIs.push_back(PN); } -- cgit v1.2.3