From e8e122ad89e7bd5084819aba04fdeee5274fe1b1 Mon Sep 17 00:00:00 2001 From: Max Kazantsev Date: Fri, 27 Oct 2017 08:19:35 +0000 Subject: [PATCH] [GVN][NFC] Refactor loop iteration with foreach git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316748 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/GVN.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 9d2c7b977f2..d7dcfd2eb16 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -2065,12 +2065,12 @@ bool GVN::processBlock(BasicBlock *BB) { if (!AtStart) --BI; - for (SmallVectorImpl::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(); -- 2.40.0