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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188605 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Joerg Sonnenberger 2013-08-17 11:04:47 +00:00
parent 913da2b7b3
commit 190673610f

View File

@ -1895,12 +1895,14 @@ bool SLPVectorizer::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
if (Incoming.size() > 1) if (Incoming.size() > 1)
Changed |= tryToVectorizeList(Incoming, R); Changed |= tryToVectorizeList(Incoming, R);
for (BasicBlock::iterator it = BB->begin(), e = BB->end(); it != e; ++it) { llvm::Instruction *I;
if (isa<DbgInfoIntrinsic>(it)) for (BasicBlock::iterator it = BB->begin(), e = BB->end(); it != e;) {
I = it++;
if (isa<DbgInfoIntrinsic>(I))
continue; continue;
// Try to vectorize reductions that use PHINodes. // 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. // Check that the PHI is a reduction PHI.
if (P->getNumIncomingValues() != 2) if (P->getNumIncomingValues() != 2)
return Changed; return Changed;
@ -1922,7 +1924,7 @@ bool SLPVectorizer::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
} }
// Try to vectorize trees that start at compare instructions. // 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)) { if (tryToVectorizePair(CI->getOperand(0), CI->getOperand(1), R)) {
Changed |= true; Changed |= true;
continue; continue;