From ea0bb8f5551adf9537e9159f785e2c6ae5dae3cb Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 30 Sep 2009 20:54:16 +0000 Subject: 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 --- llvm/lib/Transforms/Utils/LoopSimplify.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Transforms/Utils/LoopSimplify.cpp') 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 *> &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); } -- cgit v1.2.3