Fix FoldSingleEntryPHINodes to update memdep and AA when it deletes
[oota-llvm.git] / lib / Transforms / Scalar / GVN.cpp
index b7fc9c30e06d6a3b3e1f542a0023046bff432535..a4bd7c1eb4234d4a7d93ac5f2bb011b520b914ce 100644 (file)
@@ -1741,8 +1741,8 @@ bool GVN::runOnFunction(Function& F) {
   // Merge unconditional branches, allowing PRE to catch more
   // optimization opportunities.
   for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ) {
-    BasicBlock *BB = FI;
-    ++FI;
+    BasicBlock *BB = FI++;
+    
     bool removedBlock = MergeBlockIntoPredecessor(BB, this);
     if (removedBlock) ++NumGVNBlocks;