Don't forget to link type names together too. Fix for Olden/mst benchmark
[oota-llvm.git] / lib / VMCore / Dominators.cpp
index d349314a1a958a28c1c7928d9bfaad250e47f606..c241646b636441346340b4475e91e8348d752612 100644 (file)
@@ -6,8 +6,9 @@
 
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/Analysis/SimplifyCFG.h"   // To get cfg::UnifyAllExitNodes
-#include "llvm/CFG.h"
+#include "llvm/Support/DepthFirstIterator.h"
 #include "llvm/Support/STLExtras.h"
+#include "llvm/Method.h"
 #include <algorithm>
 
 //===----------------------------------------------------------------------===//
@@ -59,10 +60,11 @@ void cfg::DominatorSet::calcForwardDominatorSet(const Method *M) {
     Changed = false;
 
     DomSetType WorkingSet;
-    df_const_iterator It = df_begin(M), End = df_end(M);
+    df_iterator<const Method*> It = df_begin(M), End = df_end(M);
     for ( ; It != End; ++It) {
       const BasicBlock *BB = *It;
-      pred_const_iterator PI = pred_begin(BB), PEnd = pred_end(BB);
+      BasicBlock::pred_const_iterator PI = BB->pred_begin(),
+                                      PEnd = BB->pred_end();
       if (PI != PEnd) {                // Is there SOME predecessor?
        // Loop until we get to a predecessor that has had it's dom set filled
        // in at least once.  We are guaranteed to have this because we are
@@ -110,10 +112,11 @@ cfg::DominatorSet::DominatorSet(Method *M, bool PostDomSet)
 
     set<const BasicBlock*> Visited;
     DomSetType WorkingSet;
-    idf_const_iterator It = idf_begin(Root), End = idf_end(Root);
+    idf_iterator<const BasicBlock*> It = idf_begin(Root), End = idf_end(Root);
     for ( ; It != End; ++It) {
       const BasicBlock *BB = *It;
-      succ_const_iterator PI = succ_begin(BB), PEnd = succ_end(BB);
+      BasicBlock::succ_const_iterator PI = BB->succ_begin(),
+                                      PEnd = BB->succ_end();
       if (PI != PEnd) {                // Is there SOME predecessor?
        // Loop until we get to a successor that has had it's dom set filled
        // in at least once.  We are guaranteed to have this because we are
@@ -201,7 +204,7 @@ cfg::DominatorTree::DominatorTree(const ImmediateDominators &IDoms)
   Nodes[Root] = new Node(Root, 0);   // Add a node for the root...
 
   // Iterate over all nodes in depth first order...
-  for (df_const_iterator I = df_begin(M), E = df_end(M); I != E; ++I) {
+  for (df_iterator<const Method*> I = df_begin(M), E = df_end(M); I != E; ++I) {
     const BasicBlock *BB = *I, *IDom = IDoms[*I];
 
     if (IDom != 0) {   // Ignore the root node and other nasty nodes
@@ -223,16 +226,17 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) {
 
   if (!isPostDominator()) {
     // Iterate over all nodes in depth first order...
-    for (df_const_iterator I = df_begin(Root), E = df_end(Root); I != E; ++I) {
+    for (df_iterator<const BasicBlock*> I = df_begin(Root), E = df_end(Root);
+         I != E; ++I) {
       const BasicBlock *BB = *I;
       const DominatorSet::DomSetType &Dominators = DS.getDominators(BB);
       unsigned DomSetSize = Dominators.size();
       if (DomSetSize == 1) continue;  // Root node... IDom = null
       
-      // Loop over all dominators of this node.  This corresponds to looping over
+      // Loop over all dominators of this node. This corresponds to looping over
       // nodes in the dominator chain, looking for a node whose dominator set is
       // equal to the current nodes, except that the current node does not exist
-      // in it.  This means that it is one level higher in the dom chain than the
+      // in it. This means that it is one level higher in the dom chain than the
       // current node, and it is our idom!  We know that we have already added
       // a DominatorTree node for our idom, because the idom must be a
       // predecessor in the depth first order that we are iterating through the
@@ -241,11 +245,11 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) {
       DominatorSet::DomSetType::const_iterator I = Dominators.begin();
       DominatorSet::DomSetType::const_iterator End = Dominators.end();
       for (; I != End; ++I) {   // Iterate over dominators...
-       // All of our dominators should form a chain, where the number of elements
-       // in the dominator set indicates what level the node is at in the chain.
-       // We want the node immediately above us, so it will have an identical 
-       // dominator set, except that BB will not dominate it... therefore it's
-       // dominator set size will be one less than BB's...
+       // All of our dominators should form a chain, where the number of
+       // elements in the dominator set indicates what level the node is at in
+       // the chain.  We want the node immediately above us, so it will have
+       // an identical dominator set, except that BB will not dominate it...
+       // therefore it's dominator set size will be one less than BB's...
        //
        if (DS.getDominators(*I).size() == DomSetSize - 1) {
          // We know that the immediate dominator should already have a node, 
@@ -263,20 +267,21 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) {
     }
   } else if (Root) {
     // Iterate over all nodes in depth first order...
-    for (idf_const_iterator I = idf_begin(Root), E = idf_end(Root); I != E; ++I) {
+    for (idf_iterator<const BasicBlock*> I = idf_begin(Root), E = idf_end(Root);
+         I != E; ++I) {
       const BasicBlock *BB = *I;
       const DominatorSet::DomSetType &Dominators = DS.getDominators(BB);
       unsigned DomSetSize = Dominators.size();
       if (DomSetSize == 1) continue;  // Root node... IDom = null
       
-      // Loop over all dominators of this node.  This corresponds to looping over
-      // nodes in the dominator chain, looking for a node whose dominator set is
-      // equal to the current nodes, except that the current node does not exist
-      // in it.  This means that it is one level higher in the dom chain than the
-      // current node, and it is our idom!  We know that we have already added
-      // a DominatorTree node for our idom, because the idom must be a
-      // predecessor in the depth first order that we are iterating through the
-      // method.
+      // Loop over all dominators of this node.  This corresponds to looping
+      // over nodes in the dominator chain, looking for a node whose dominator
+      // set is equal to the current nodes, except that the current node does
+      // not exist in it.  This means that it is one level higher in the dom
+      // chain than the current node, and it is our idom!  We know that we have
+      // already added a DominatorTree node for our idom, because the idom must
+      // be a predecessor in the depth first order that we are iterating through
+      // the method.
       //
       DominatorSet::DomSetType::const_iterator I = Dominators.begin();
       DominatorSet::DomSetType::const_iterator End = Dominators.end();
@@ -317,8 +322,8 @@ cfg::DominanceFrontier::calcDomFrontier(const DominatorTree &DT,
   const BasicBlock *BB = Node->getNode();
   DomSetType &S = Frontiers[BB];       // The new set to fill in...
 
-  for (succ_const_iterator SI = succ_begin(BB), SE = succ_end(BB); 
-       SI != SE; ++SI) {
+  for (BasicBlock::succ_const_iterator SI = BB->succ_begin(),
+                                       SE = BB->succ_end(); SI != SE; ++SI) {
     // Does Node immediately dominate this successor?
     if (DT[*SI]->getIDom() != Node)
       S.insert(*SI);
@@ -351,8 +356,8 @@ cfg::DominanceFrontier::calcPostDomFrontier(const DominatorTree &DT,
   DomSetType &S = Frontiers[BB];       // The new set to fill in...
   if (!Root) return S;
 
-  for (pred_const_iterator SI = pred_begin(BB), SE = pred_end(BB); 
-       SI != SE; ++SI) {
+  for (BasicBlock::pred_const_iterator SI = BB->pred_begin(),
+                                       SE = BB->pred_end(); SI != SE; ++SI) {
     // Does Node immediately dominate this predeccessor?
     if (DT[*SI]->getIDom() != Node)
       S.insert(*SI);