[llvm] r265625 - Follow-up for r265605: don't mutate vector we're iterating.
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 6 17:09:44 PDT 2016
Author: mzolotukhin
Date: Wed Apr 6 19:09:42 2016
New Revision: 265625
URL: http://llvm.org/viewvc/llvm-project?rev=265625&view=rev
Log:
Follow-up for r265605: don't mutate vector we're iterating.
Modified:
llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp
Modified: llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp?rev=265625&r1=265624&r2=265625&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp Wed Apr 6 19:09:42 2016
@@ -563,13 +563,15 @@ bool llvm::UnrollLoop(Loop *L, unsigned
if (DT && Count > 1) {
for (auto *BB : OriginalLoopBlocks) {
auto *BBDomNode = DT->getNode(BB);
+ SmallVector<BasicBlock *, 16> ChildrenToUpdate;
for (auto *ChildDomNode : BBDomNode->getChildren()) {
auto *ChildBB = ChildDomNode->getBlock();
- if (L->contains(ChildBB))
- continue;
- BasicBlock *NewIDom = DT->findNearestCommonDominator(BB, Latches[0]);
- DT->changeImmediateDominator(ChildBB, NewIDom);
+ if (!L->contains(ChildBB))
+ ChildrenToUpdate.push_back(ChildBB);
}
+ BasicBlock *NewIDom = DT->findNearestCommonDominator(BB, Latches[0]);
+ for (auto *ChildBB : ChildrenToUpdate)
+ DT->changeImmediateDominator(ChildBB, NewIDom);
}
}
More information about the llvm-commits
mailing list