diff options
author | Devang Patel <dpatel@apple.com> | 2007-06-11 21:18:00 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-06-11 21:18:00 +0000 |
commit | e3f653606def60bf7e81c7e5d126f02c6f8b1360 (patch) | |
tree | 8948940837d24855f53b61e55f81225666e7dd1f /lib/Transforms/Utils/LoopSimplify.cpp | |
parent | 0e71466405344a3d82ef57ec1168e30e7c39f7da (diff) |
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
Diffstat (limited to 'lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r-- | lib/Transforms/Utils/LoopSimplify.cpp | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index 5fc750a60f..4a98b3fd35 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<BasicBlock*>& 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<DominatorTree>()) { - // 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... |