aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2007-04-07 07:17:27 +0000
committerOwen Anderson <resistor@mac.com>2007-04-07 07:17:27 +0000
commitba43963e96c9eb28d4f6862e46c5d3fbdc1f3b96 (patch)
treec7431cd8d0b9ae7636f55866f7afbf1f76bb827a /lib/VMCore
parent4f9e58ecdf247f87a9b7cef69b1fa37fb5b07f0d (diff)
downloadexternal_llvm-ba43963e96c9eb28d4f6862e46c5d3fbdc1f3b96.zip
external_llvm-ba43963e96c9eb28d4f6862e46c5d3fbdc1f3b96.tar.gz
external_llvm-ba43963e96c9eb28d4f6862e46c5d3fbdc1f3b96.tar.bz2
Completely purge DomSet. This is the (hopefully) final patch for PR1171.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35731 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Dominators.cpp123
1 files changed, 14 insertions, 109 deletions
diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp
index 9bd51bf..4988049 100644
--- a/lib/VMCore/Dominators.cpp
+++ b/lib/VMCore/Dominators.cpp
@@ -251,113 +251,6 @@ void ImmediateDominatorsBase::print(std::ostream &o, const Module* ) const {
o << "\n";
}
-
-
-//===----------------------------------------------------------------------===//
-// DominatorSet Implementation
-//===----------------------------------------------------------------------===//
-
-static RegisterPass<DominatorSet>
-B("domset", "Dominator Set Construction", true);
-
-// dominates - Return true if A dominates B. This performs the special checks
-// necessary if A and B are in the same basic block.
-//
-bool DominatorSetBase::dominates(Instruction *A, Instruction *B) const {
- BasicBlock *BBA = A->getParent(), *BBB = B->getParent();
- if (BBA != BBB) return dominates(BBA, BBB);
-
- // It is not possible to determine dominance between two PHI nodes
- // based on their ordering.
- if (isa<PHINode>(A) && isa<PHINode>(B))
- return false;
-
- // Loop through the basic block until we find A or B.
- BasicBlock::iterator I = BBA->begin();
- for (; &*I != A && &*I != B; ++I) /*empty*/;
-
- if(!IsPostDominators) {
- // A dominates B if it is found first in the basic block.
- return &*I == A;
- } else {
- // A post-dominates B if B is found first in the basic block.
- return &*I == B;
- }
-}
-
-
-// runOnFunction - This method calculates the forward dominator sets for the
-// specified function.
-//
-bool DominatorSet::runOnFunction(Function &F) {
- BasicBlock *Root = &F.getEntryBlock();
- Roots.clear();
- Roots.push_back(Root);
- assert(pred_begin(Root) == pred_end(Root) &&
- "Root node has predecessors in function!");
-
- ImmediateDominators &ID = getAnalysis<ImmediateDominators>();
- Doms.clear();
- if (Roots.empty()) return false;
-
- // Root nodes only dominate themselves.
- for (unsigned i = 0, e = Roots.size(); i != e; ++i)
- Doms[Roots[i]].insert(Roots[i]);
-
- // Loop over all of the blocks in the function, calculating dominator sets for
- // each function.
- for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
- if (BasicBlock *IDom = ID[I]) { // Get idom if block is reachable
- DomSetType &DS = Doms[I];
- assert(DS.empty() && "Domset already filled in for this block?");
- DS.insert(I); // Blocks always dominate themselves
-
- // Insert all dominators into the set...
- while (IDom) {
- // If we have already computed the dominator sets for our immediate
- // dominator, just use it instead of walking all the way up to the root.
- DomSetType &IDS = Doms[IDom];
- if (!IDS.empty()) {
- DS.insert(IDS.begin(), IDS.end());
- break;
- } else {
- DS.insert(IDom);
- IDom = ID[IDom];
- }
- }
- } else {
- // Ensure that every basic block has at least an empty set of nodes. This
- // is important for the case when there is unreachable blocks.
- Doms[I];
- }
-
- return false;
-}
-
-namespace llvm {
-static std::ostream &operator<<(std::ostream &o,
- const std::set<BasicBlock*> &BBs) {
- for (std::set<BasicBlock*>::const_iterator I = BBs.begin(), E = BBs.end();
- I != E; ++I)
- if (*I)
- WriteAsOperand(o, *I, false);
- else
- o << " <<exit node>>";
- return o;
-}
-}
-
-void DominatorSetBase::print(std::ostream &o, const Module* ) const {
- for (const_iterator I = begin(), E = end(); I != E; ++I) {
- o << " DomSet For BB: ";
- if (I->first)
- WriteAsOperand(o, I->first, false);
- else
- o << " <<exit node>>";
- o << " is:\t" << I->second << "\n";
- }
-}
-
//===----------------------------------------------------------------------===//
// DominatorTree Implementation
//===----------------------------------------------------------------------===//
@@ -528,6 +421,20 @@ DominanceFrontier::calculate(const DominatorTree &DT,
return *Result;
}
+namespace llvm {
+static std::ostream &operator<<(std::ostream &o,
+ const std::set<BasicBlock*> &BBs) {
+ for (std::set<BasicBlock*>::const_iterator I = BBs.begin(), E = BBs.end();
+ I != E; ++I)
+ if (*I)
+ WriteAsOperand(o, *I, false);
+ else
+ o << " <<exit node>>";
+ return o;
+}
+}
+
+
void DominanceFrontierBase::print(std::ostream &o, const Module* ) const {
for (const_iterator I = begin(), E = end(); I != E; ++I) {
o << " DomFrontier for BB";
@@ -1071,5 +978,3 @@ void ETForestBase::print(std::ostream &o, const Module *) const {
}
o << "\n";
}
-
-DEFINING_FILE_FOR(DominatorSet)