summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/TailRecursionElimination.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-09-20 05:24:00 +0000
committerChris Lattner <sabre@nondot.org>2003-09-20 05:24:00 +0000
commitd452ebd0bfcba6ba017390c392b81c080e362f28 (patch)
treebda4cd81c6152f167fe50f40828b14f08654a420 /lib/Transforms/Scalar/TailRecursionElimination.cpp
parent3fc6ef1bb96d9a3194cef667a2d3cbc94e3fb189 (diff)
downloadllvm-d452ebd0bfcba6ba017390c392b81c080e362f28.tar.gz
llvm-d452ebd0bfcba6ba017390c392b81c080e362f28.tar.bz2
llvm-d452ebd0bfcba6ba017390c392b81c080e362f28.tar.xz
Fix a really obvious huge gaping bug, add a comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8620 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/TailRecursionElimination.cpp')
-rw-r--r--lib/Transforms/Scalar/TailRecursionElimination.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp
index 3945af3db7..c8ac4c5ff7 100644
--- a/lib/Transforms/Scalar/TailRecursionElimination.cpp
+++ b/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<ReturnInst>(BB->getTerminator()))
- if (Ret != BB->begin())
+ if (Ret != BB->begin()) // Make sure there is something before the ret...
if (CallInst *CI = dyn_cast<CallInst>(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);
}