[llvm-commits] CVS: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Sep 20 00:25:03 PDT 2003
Changes in directory llvm/lib/Transforms/Scalar:
TailRecursionElimination.cpp updated: 1.2 -> 1.3
---
Log message:
Fix a really obvious huge gaping bug, add a comment
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
diff -u llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:1.2 llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:1.3
--- llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:1.2 Sat Sep 20 00:14:13 2003
+++ llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp Sat Sep 20 00:24:00 2003
@@ -50,7 +50,7 @@
// 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 @@
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);
}
More information about the llvm-commits
mailing list