[llvm] r188605 - PR 16899: Do not modify the basic block using the iterator, but keep the
Joerg Sonnenberger
joerg at bec.de
Sat Aug 17 04:04:49 PDT 2013
Author: joerg
Date: Sat Aug 17 06:04:47 2013
New Revision: 188605
URL: http://llvm.org/viewvc/llvm-project?rev=188605&view=rev
Log:
PR 16899: Do not modify the basic block using the iterator, but keep the
next value. This avoids crashes due to invalidation.
Patch by Joey Gouly.
Modified:
llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=188605&r1=188604&r2=188605&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Sat Aug 17 06:04:47 2013
@@ -1895,12 +1895,14 @@ bool SLPVectorizer::vectorizeChainsInBlo
if (Incoming.size() > 1)
Changed |= tryToVectorizeList(Incoming, R);
- for (BasicBlock::iterator it = BB->begin(), e = BB->end(); it != e; ++it) {
- if (isa<DbgInfoIntrinsic>(it))
+ llvm::Instruction *I;
+ for (BasicBlock::iterator it = BB->begin(), e = BB->end(); it != e;) {
+ I = it++;
+ if (isa<DbgInfoIntrinsic>(I))
continue;
// Try to vectorize reductions that use PHINodes.
- if (PHINode *P = dyn_cast<PHINode>(it)) {
+ if (PHINode *P = dyn_cast<PHINode>(I)) {
// Check that the PHI is a reduction PHI.
if (P->getNumIncomingValues() != 2)
return Changed;
@@ -1922,7 +1924,7 @@ bool SLPVectorizer::vectorizeChainsInBlo
}
// Try to vectorize trees that start at compare instructions.
- if (CmpInst *CI = dyn_cast<CmpInst>(it)) {
+ if (CmpInst *CI = dyn_cast<CmpInst>(I)) {
if (tryToVectorizePair(CI->getOperand(0), CI->getOperand(1), R)) {
Changed |= true;
continue;
More information about the llvm-commits
mailing list