diff options
author | Dan Gohman <gohman@apple.com> | 2009-09-30 20:54:16 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-09-30 20:54:16 +0000 |
commit | ea0bb8f5551adf9537e9159f785e2c6ae5dae3cb (patch) | |
tree | 59bbbd6041b6619191830ddf605adb6d034edcb7 /llvm/lib/Transforms/Utils/LoopSimplify.cpp | |
parent | fd2dcba7f3a6953771cb98b46278071e2c01cd26 (diff) | |
download | bcm5719-llvm-ea0bb8f5551adf9537e9159f785e2c6ae5dae3cb.tar.gz bcm5719-llvm-ea0bb8f5551adf9537e9159f785e2c6ae5dae3cb.zip |
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.
llvm-svn: 83166
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopSimplify.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index ffa12bfb7f0..c22708a92b7 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/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); } |