From e3f653606def60bf7e81c7e5d126f02c6f8b1360 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 11 Jun 2007 21:18:00 +0000 Subject: [PATCH] Simplify. Dominator Tree is required so always available. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37540 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/LoopSimplify.cpp | 57 ++++++++++++--------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index 5fc750a60f3..4a98b3fd355 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -693,9 +693,8 @@ static bool BlockDominatesAny(BasicBlock* A, const std::vector& B, return false; } -/// UpdateDomInfoForRevectoredPreds - This method is used to update the four -/// different kinds of dominator information (immediate dominators, -/// dominator trees, et-forest and dominance frontiers) after a new block has +/// UpdateDomInfoForRevectoredPreds - This method is used to update +/// dominator trees and dominance frontiers after a new block has /// been added to the CFG. /// /// This only supports the case when an existing block (known as "NewBBSucc"), @@ -756,38 +755,34 @@ void LoopSimplify::UpdateDomInfoForRevectoredPreds(BasicBlock *NewBB, } } - BasicBlock *NewBBIDom = 0; // Update DominatorTree information if it is active. - if (DominatorTree *DT = getAnalysisToUpdate()) { - // If we don't have ImmediateDominator info around, calculate the idom as - // above. - if (!NewBBIDom) { - unsigned i = 0; - for (i = 0; i < PredBlocks.size(); ++i) - if (DT->dominates(&PredBlocks[i]->getParent()->getEntryBlock(), - PredBlocks[i])) { - NewBBIDom = PredBlocks[i]; - break; - } - assert(i != PredBlocks.size() && "No reachable preds?"); - for (i = i + 1; i < PredBlocks.size(); ++i) { - if (DT->dominates(&PredBlocks[i]->getParent()->getEntryBlock(), - PredBlocks[i])) - NewBBIDom = DT->nearestCommonDominator(NewBBIDom, PredBlocks[i]); - } - assert(NewBBIDom && "No immediate dominator found??"); - } - // Create the new dominator tree node... and set the idom of NewBB. - DomTreeNode *NewBBNode = DT->addNewBlock(NewBB, NewBBIDom); - - // If NewBB strictly dominates other blocks, then it is now the immediate - // dominator of NewBBSucc. Update the dominator tree as appropriate. - if (NewBBDominatesNewBBSucc) { - DomTreeNode *NewBBSuccNode = DT->getNode(NewBBSucc); - DT->changeImmediateDominator(NewBBSuccNode, NewBBNode); + // Find NewBB's immediate dominator and create new dominator tree node for NewBB. + BasicBlock *NewBBIDom = 0; + unsigned i = 0; + for (i = 0; i < PredBlocks.size(); ++i) + if (DT.dominates(&PredBlocks[i]->getParent()->getEntryBlock(), + PredBlocks[i])) { + NewBBIDom = PredBlocks[i]; + break; } + assert(i != PredBlocks.size() && "No reachable preds?"); + for (i = i + 1; i < PredBlocks.size(); ++i) { + if (DT.dominates(&PredBlocks[i]->getParent()->getEntryBlock(), + PredBlocks[i])) + NewBBIDom = DT.nearestCommonDominator(NewBBIDom, PredBlocks[i]); + } + assert(NewBBIDom && "No immediate dominator found??"); + + // Create the new dominator tree node... and set the idom of NewBB. + DomTreeNode *NewBBNode = DT.addNewBlock(NewBB, NewBBIDom); + + // If NewBB strictly dominates other blocks, then it is now the immediate + // dominator of NewBBSucc. Update the dominator tree as appropriate. + if (NewBBDominatesNewBBSucc) { + DomTreeNode *NewBBSuccNode = DT.getNode(NewBBSucc); + DT.changeImmediateDominator(NewBBSuccNode, NewBBNode); } // Update dominance frontier information...