]> granicus.if.org Git - llvm/commitdiff
Correct a glitch in r194424 which may invalidate iterator.
authorShuxin Yang <shuxin.llvm@gmail.com>
Tue, 12 Nov 2013 08:33:03 +0000 (08:33 +0000)
committerShuxin Yang <shuxin.llvm@gmail.com>
Tue, 12 Nov 2013 08:33:03 +0000 (08:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194457 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/GVN.cpp

index d353765b42ae9e6c38e4407603caacd204780a88..6af269dfed32ef184ee1c883a8d91f78fa40a9a1 100644 (file)
@@ -2730,7 +2730,9 @@ void GVN::addDeadBlock(BasicBlock *BB) {
     if (DeadBlocks.count(B))
       continue;
 
-    for (pred_iterator PI = pred_begin(B), PE = pred_end(B); PI != PE; PI++) {
+    SmallVector<BasicBlock *, 4> Preds(pred_begin(B), pred_end(B));
+    for (SmallVectorImpl<BasicBlock *>::iterator PI = Preds.begin(),
+           PE = Preds.end(); PI != PE; PI++) {
       BasicBlock *P = *PI;
 
       if (!DeadBlocks.count(P))