summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/LoopSimplify.cpp
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
commit5184635eda68a0cdcd39c958ccc11ba1843bcc7b (patch)
tree718ce2d7bf5590452ba09218741077b86e55a1b4 /lib/Transforms/Utils/LoopSimplify.cpp
parent3a90c9b8edb53ea1ea57d94f7ab256608b5b30c6 (diff)
downloadllvm-5184635eda68a0cdcd39c958ccc11ba1843bcc7b.tar.gz
llvm-5184635eda68a0cdcd39c958ccc11ba1843bcc7b.tar.bz2
llvm-5184635eda68a0cdcd39c958ccc11ba1843bcc7b.tar.xz
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
Diffstat (limited to 'lib/Transforms/Utils/LoopSimplify.cpp')
-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 ffa12bfb7f..c22708a92b 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);
}