[llvm] r316748 - [GVN][NFC] Refactor loop iteration with foreach
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 27 01:19:35 PDT 2017
Author: mkazantsev
Date: Fri Oct 27 01:19:35 2017
New Revision: 316748
URL: http://llvm.org/viewvc/llvm-project?rev=316748&view=rev
Log:
[GVN][NFC] Refactor loop iteration with foreach
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=316748&r1=316747&r2=316748&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Fri Oct 27 01:19:35 2017
@@ -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();
More information about the llvm-commits
mailing list