aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-09-30 20:54:16 +0000
committerDan Gohman <gohman@apple.com>2009-09-30 20:54:16 +0000
commita6c9ec0753ed03948b49ae3e0d96b87b484ee247 (patch)
tree718ce2d7bf5590452ba09218741077b86e55a1b4
parent64ccb3919aa594caf4c2196eed9e72cc9797fe57 (diff)
downloadexternal_llvm-a6c9ec0753ed03948b49ae3e0d96b87b484ee247.zip
external_llvm-a6c9ec0753ed03948b49ae3e0d96b87b484ee247.tar.gz
external_llvm-a6c9ec0753ed03948b49ae3e0d96b87b484ee247.tar.bz2
Fix this code so that it doesn't try to iterate through a std::vector
while calling changeImmediateDominator, which removes elements from the vector. This fixes PR5097. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83166 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Utils/LoopSimplify.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp
index ffa12bf..c22708a 100644
--- a/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/lib/Transforms/Utils/LoopSimplify.cpp
@@ -274,9 +274,10 @@ ReprocessLoop:
DomTreeNode *Node = DT->getNode(ExitingBlock);
const std::vector<DomTreeNodeBase<BasicBlock> *> &Children =
Node->getChildren();
- for (unsigned k = 0, g = Children.size(); k != g; ++k) {
- DT->changeImmediateDominator(Children[k], Node->getIDom());
- if (DF) DF->changeImmediateDominator(Children[k]->getBlock(),
+ while (!Children.empty()) {
+ DomTreeNode *Child = Children.front();
+ DT->changeImmediateDominator(Child, Node->getIDom());
+ if (DF) DF->changeImmediateDominator(Child->getBlock(),
Node->getIDom()->getBlock(),
DT);
}