[llvm-commits] [llvm] r40776 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Owen Anderson
resistor at mac.com
Fri Aug 3 04:03:27 PDT 2007
Author: resistor
Date: Fri Aug 3 06:03:26 2007
New Revision: 40776
URL: http://llvm.org/viewvc/llvm-project?rev=40776&view=rev
Log:
Fix a subtle iterator invalidation bug in a recursive algorithm.
Modified:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=40776&r1=40775&r2=40776&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Fri Aug 3 06:03:26 2007
@@ -726,19 +726,21 @@
bool top_level) {
// If we have already computed this value, return the previously computed val.
- Value *&V = Phis[BB];
+ Value *V = Phis[BB];
if (V && ! top_level) return V;
BasicBlock* singlePred = BB->getSinglePredecessor();
- if (singlePred)
- return V = GetValueForBlock(singlePred, orig, Phis);
-
+ if (singlePred) {
+ V = GetValueForBlock(singlePred, orig, Phis);
+ Phis[BB] = V;
+ return V;
+ }
// Otherwise, the idom is the loop, so we need to insert a PHI node. Do so
// now, then get values to fill in the incoming values for the PHI.
PHINode *PN = new PHINode(orig->getType(), orig->getName()+".rle",
BB->begin());
PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB)));
- V = PN;
+ Phis[BB] = PN;
bool all_same = true;
Value* first = 0;
More information about the llvm-commits
mailing list