]> granicus.if.org Git - llvm/commitdiff
[GVN][NFC] Refactor loop iteration with foreach
authorMax Kazantsev <max.kazantsev@azul.com>
Fri, 27 Oct 2017 08:19:35 +0000 (08:19 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Fri, 27 Oct 2017 08:19:35 +0000 (08:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316748 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/GVN.cpp

index 9d2c7b977f2e6b412ef1bdfbdcef3a2e3765573a..d7dcfd2eb1643d8368f61e5c7d9bbad1c537d8db 100644 (file)
@@ -2065,12 +2065,12 @@ bool GVN::processBlock(BasicBlock *BB) {
     if (!AtStart)
       --BI;
 
-    for (SmallVectorImpl<Instruction *>::iterator I = InstrsToErase.begin(),
-         E = InstrsToErase.end(); I != E; ++I) {
-      DEBUG(dbgs() << "GVN removed: " << **I << '\n');
-      if (MD) MD->removeInstruction(*I);
-      DEBUG(verifyRemoved(*I));
-      (*I)->eraseFromParent();
+    for (auto *I : InstrsToErase) {
+      assert(I->getParent() == BB && "Removing instruction from wrong block?");
+      DEBUG(dbgs() << "GVN removed: " << *I << '\n');
+      if (MD) MD->removeInstruction(I);
+      DEBUG(verifyRemoved(I));
+      I->eraseFromParent();
     }
     InstrsToErase.clear();