aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Dominators.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2007-10-17 02:03:17 +0000
committerOwen Anderson <resistor@mac.com>2007-10-17 02:03:17 +0000
commit10ff10ffc12c65ac741ee537b6f93c567510a5cc (patch)
tree6ec5cc2919f15ff319b9e66452b52566b8d1b39a /lib/VMCore/Dominators.cpp
parent2c9c170a9a548a02b418ecb162399ba79bdfe482 (diff)
downloadexternal_llvm-10ff10ffc12c65ac741ee537b6f93c567510a5cc.zip
external_llvm-10ff10ffc12c65ac741ee537b6f93c567510a5cc.tar.gz
external_llvm-10ff10ffc12c65ac741ee537b6f93c567510a5cc.tar.bz2
Move splitBlock into DomTreeBase from DomTree.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Dominators.cpp')
-rw-r--r--lib/VMCore/Dominators.cpp82
1 files changed, 0 insertions, 82 deletions
diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp
index a9900fe..b909a00 100644
--- a/lib/VMCore/Dominators.cpp
+++ b/lib/VMCore/Dominators.cpp
@@ -56,88 +56,6 @@ char DominatorTree::ID = 0;
static RegisterPass<DominatorTree>
E("domtree", "Dominator Tree Construction", true);
-// NewBB is split and now it has one successor. Update dominator tree to
-// reflect this change.
-void DominatorTree::splitBlock(BasicBlock *NewBB) {
- assert(NewBB->getTerminator()->getNumSuccessors() == 1
- && "NewBB should have a single successor!");
- BasicBlock *NewBBSucc = NewBB->getTerminator()->getSuccessor(0);
-
- std::vector<BasicBlock*> PredBlocks;
- for (pred_iterator PI = pred_begin(NewBB), PE = pred_end(NewBB);
- PI != PE; ++PI)
- PredBlocks.push_back(*PI);
-
- assert(!PredBlocks.empty() && "No predblocks??");
-
- // The newly inserted basic block will dominate existing basic blocks iff the
- // PredBlocks dominate all of the non-pred blocks. If all predblocks dominate
- // the non-pred blocks, then they all must be the same block!
- //
- bool NewBBDominatesNewBBSucc = true;
- {
- BasicBlock *OnePred = PredBlocks[0];
- unsigned i = 1, e = PredBlocks.size();
- for (i = 1; !isReachableFromEntry(OnePred); ++i) {
- assert(i != e && "Didn't find reachable pred?");
- OnePred = PredBlocks[i];
- }
-
- for (; i != e; ++i)
- if (PredBlocks[i] != OnePred && isReachableFromEntry(OnePred)) {
- NewBBDominatesNewBBSucc = false;
- break;
- }
-
- if (NewBBDominatesNewBBSucc)
- for (pred_iterator PI = pred_begin(NewBBSucc), E = pred_end(NewBBSucc);
- PI != E; ++PI)
- if (*PI != NewBB && !dominates(NewBBSucc, *PI)) {
- NewBBDominatesNewBBSucc = false;
- break;
- }
- }
-
- // The other scenario where the new block can dominate its successors are when
- // all predecessors of NewBBSucc that are not NewBB are dominated by NewBBSucc
- // already.
- if (!NewBBDominatesNewBBSucc) {
- NewBBDominatesNewBBSucc = true;
- for (pred_iterator PI = pred_begin(NewBBSucc), E = pred_end(NewBBSucc);
- PI != E; ++PI)
- if (*PI != NewBB && !dominates(NewBBSucc, *PI)) {
- NewBBDominatesNewBBSucc = false;
- break;
- }
- }
-
- // 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 (isReachableFromEntry(PredBlocks[i])) {
- NewBBIDom = PredBlocks[i];
- break;
- }
- assert(i != PredBlocks.size() && "No reachable preds?");
- for (i = i + 1; i < PredBlocks.size(); ++i) {
- if (isReachableFromEntry(PredBlocks[i]))
- NewBBIDom = findNearestCommonDominator(NewBBIDom, PredBlocks[i]);
- }
- assert(NewBBIDom && "No immediate dominator found??");
-
- // Create the new dominator tree node... and set the idom of NewBB.
- DomTreeNode *NewBBNode = 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 = getNode(NewBBSucc);
- changeImmediateDominator(NewBBSuccNode, NewBBNode);
- }
-}
-
bool DominatorTree::runOnFunction(Function &F) {
reset(); // Reset from the last time we were run...