Pull iterators out of CFG.h and CFGdecls and put them in Support directory
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@664 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/Interval.cpp b/lib/Analysis/Interval.cpp
index a6567ec..97fa34e 100644
--- a/lib/Analysis/Interval.cpp
+++ b/lib/Analysis/Interval.cpp
@@ -7,7 +7,6 @@
#include "llvm/Analysis/Interval.h"
#include "llvm/BasicBlock.h"
-#include "llvm/CFG.h"
using namespace cfg;
diff --git a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
index e47c9d2..898dd28 100644
--- a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
+++ b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
@@ -11,7 +11,7 @@
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
-
+#include "llvm/Support/PostOrderIterator.h"
/************************** Constructor/Destructor ***************************/
@@ -47,9 +47,9 @@
{
unsigned int POId = 0; // Reverse Depth-first Order ID
- cfg::po_const_iterator BBI = cfg::po_begin(Meth);
+ po_iterator<const Method*> BBI = po_begin(Meth);
- for( ; BBI != cfg::po_end(Meth) ; ++BBI, ++POId)
+ for( ; BBI != po_end(Meth) ; ++BBI, ++POId)
{
if(DEBUG_LV) cout << " For BB " << (*BBI)->getName() << ":" << endl ;
@@ -77,9 +77,9 @@
if(DEBUG_LV)
cout << endl << " After Backward Pass ..." << endl;
- cfg::po_const_iterator BBI = cfg::po_begin(Meth);
+ po_iterator<const Method*> BBI = po_begin(Meth);
- for( ; BBI != cfg::po_end(Meth) ; ++BBI)
+ for( ; BBI != po_end(Meth) ; ++BBI)
{
BBLiveVar* LVBB = BB2BBLVMap[*BBI];
diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp
index d349314..0372141 100644
--- a/lib/Analysis/PostDominators.cpp
+++ b/lib/Analysis/PostDominators.cpp
@@ -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,7 +60,7 @@
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);
@@ -110,7 +111,7 @@
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);
@@ -201,7 +202,7 @@
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 +224,17 @@
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 +243,11 @@
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 +265,21 @@
}
} 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();
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index 591b8e8..33f46fc 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -21,8 +21,8 @@
#include "llvm/DerivedTypes.h"
#include "llvm/iTerminators.h"
#include "llvm/iMemory.h"
-#include "llvm/CFG.h" // TODO: Change this when we have a DF.h
#include "llvm/Support/STLExtras.h"
+#include "llvm/Support/DepthFirstIterator.h"
#include <list>
#include <utility> // Get definition of pair class
#include <algorithm>
@@ -417,7 +417,7 @@
// TypeContains - Returns true if Ty contains E in it.
//
static bool TypeContains(const Type *Ty, const Type *E) {
- return find(cfg::tdf_begin(Ty), cfg::tdf_end(Ty), E) != cfg::tdf_end(Ty);
+ return find(df_begin(Ty), df_end(Ty), E) != df_end(Ty);
}
diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h
index b94b791..ed4f1a4 100644
--- a/lib/Bytecode/Reader/ReaderInternals.h
+++ b/lib/Bytecode/Reader/ReaderInternals.h
@@ -13,6 +13,7 @@
#include "llvm/Instruction.h"
#include <map>
#include <utility>
+#include <list>
// Enable to trace to figure out what the heck is going on when parsing fails
#define TRACE_LEVEL 0
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index 0ac371c..cac8f2e 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -20,7 +20,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/SymbolTable.h"
#include "llvm/Support/STLExtras.h"
-#include "llvm/CFG.h"
+#include "llvm/Support/DepthFirstIterator.h"
#include <algorithm>
#if 0
@@ -264,8 +264,8 @@
// the type itself is. This also assures us that we will not hit infinite
// recursion on recursive types...
//
- for (cfg::tdf_iterator I = cfg::tdf_begin(TheTy, true),
- E = cfg::tdf_end(TheTy); I != E; ++I)
+ for (df_iterator<const Type*> I = df_begin(TheTy, true),
+ E = df_end(TheTy); I != E; ++I)
if (*I != TheTy) {
// If we haven't seen this sub type before, add it to our type table!
const Type *SubTy = *I;
diff --git a/lib/CodeGen/InstrSched/SchedGraph.h b/lib/CodeGen/InstrSched/SchedGraph.h
index 5c4a600..ef3b4df 100644
--- a/lib/CodeGen/InstrSched/SchedGraph.h
+++ b/lib/CodeGen/InstrSched/SchedGraph.h
@@ -19,13 +19,14 @@
#ifndef LLVM_CODEGEN_SCHEDGRAPH_H
#define LLVM_CODEGEN_SCHEDGRAPH_H
-#include "llvm/CFGdecls.h" // just for graph iterators
#include "llvm/Support/NonCopyable.h"
#include "llvm/Support/HashExtras.h"
+#include "llvm/Support/GraphTraits.h"
#include <hash_map>
class Value;
class Instruction;
+class TerminatorInst;
class BasicBlock;
class Method;
class TargetMachine;
@@ -480,13 +481,36 @@
return sg_succ_const_iterator(N->endOutEdges());
}
-//
-// po_iterator
-// po_const_iterator
+// Provide specializations of GraphTraits to be able to use graph iterators on
+// the scheduling graph!
//
-typedef cfg::POIterator<SchedGraphNode, sg_succ_iterator> sg_po_iterator;
-typedef cfg::POIterator<const SchedGraphNode,
- sg_succ_const_iterator> sg_po_const_iterator;
+template <> struct GraphTraits<SchedGraph*> {
+ typedef SchedGraphNode NodeType;
+ typedef sg_succ_iterator ChildIteratorType;
+
+ static inline NodeType *getEntryNode(SchedGraph *SG) { return SG->getRoot(); }
+ static inline ChildIteratorType child_begin(NodeType *N) {
+ return succ_begin(N);
+ }
+ static inline ChildIteratorType child_end(NodeType *N) {
+ return succ_end(N);
+ }
+};
+
+template <> struct GraphTraits<const SchedGraph*> {
+ typedef const SchedGraphNode NodeType;
+ typedef sg_succ_const_iterator ChildIteratorType;
+
+ static inline NodeType *getEntryNode(const SchedGraph *SG) {
+ return SG->getRoot();
+ }
+ static inline ChildIteratorType child_begin(NodeType *N) {
+ return succ_begin(N);
+ }
+ static inline ChildIteratorType child_end(NodeType *N) {
+ return succ_end(N);
+ }
+};
//************************ External Functions *****************************/
diff --git a/lib/CodeGen/InstrSched/SchedPriorities.cpp b/lib/CodeGen/InstrSched/SchedPriorities.cpp
index 9e2053b..7840a25 100644
--- a/lib/CodeGen/InstrSched/SchedPriorities.cpp
+++ b/lib/CodeGen/InstrSched/SchedPriorities.cpp
@@ -19,6 +19,7 @@
//**************************************************************************/
#include "SchedPriorities.h"
+#include "llvm/Support/PostOrderIterator.h"
SchedPriorities::SchedPriorities(const Method* method,
@@ -50,8 +51,7 @@
void
SchedPriorities::computeDelays(const SchedGraph* graph)
{
- sg_po_const_iterator poIter = sg_po_const_iterator::begin(graph->getRoot());
- sg_po_const_iterator poEnd = sg_po_const_iterator::end( graph->getRoot());
+ po_iterator<const SchedGraph*> poIter = po_begin(graph), poEnd =po_end(graph);
for ( ; poIter != poEnd; ++poIter)
{
const SchedGraphNode* node = *poIter;
diff --git a/lib/CodeGen/InstrSched/SchedPriorities.h b/lib/CodeGen/InstrSched/SchedPriorities.h
index 909f4ed..81a2e6a 100644
--- a/lib/CodeGen/InstrSched/SchedPriorities.h
+++ b/lib/CodeGen/InstrSched/SchedPriorities.h
@@ -25,6 +25,7 @@
#include "llvm/CodeGen/InstrScheduling.h"
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
#include "llvm/Target/MachineSchedInfo.h"
+#include <list>
class Method;
class MachineInstr;
diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.h b/lib/Target/SparcV9/InstrSched/SchedGraph.h
index 5c4a600..ef3b4df 100644
--- a/lib/Target/SparcV9/InstrSched/SchedGraph.h
+++ b/lib/Target/SparcV9/InstrSched/SchedGraph.h
@@ -19,13 +19,14 @@
#ifndef LLVM_CODEGEN_SCHEDGRAPH_H
#define LLVM_CODEGEN_SCHEDGRAPH_H
-#include "llvm/CFGdecls.h" // just for graph iterators
#include "llvm/Support/NonCopyable.h"
#include "llvm/Support/HashExtras.h"
+#include "llvm/Support/GraphTraits.h"
#include <hash_map>
class Value;
class Instruction;
+class TerminatorInst;
class BasicBlock;
class Method;
class TargetMachine;
@@ -480,13 +481,36 @@
return sg_succ_const_iterator(N->endOutEdges());
}
-//
-// po_iterator
-// po_const_iterator
+// Provide specializations of GraphTraits to be able to use graph iterators on
+// the scheduling graph!
//
-typedef cfg::POIterator<SchedGraphNode, sg_succ_iterator> sg_po_iterator;
-typedef cfg::POIterator<const SchedGraphNode,
- sg_succ_const_iterator> sg_po_const_iterator;
+template <> struct GraphTraits<SchedGraph*> {
+ typedef SchedGraphNode NodeType;
+ typedef sg_succ_iterator ChildIteratorType;
+
+ static inline NodeType *getEntryNode(SchedGraph *SG) { return SG->getRoot(); }
+ static inline ChildIteratorType child_begin(NodeType *N) {
+ return succ_begin(N);
+ }
+ static inline ChildIteratorType child_end(NodeType *N) {
+ return succ_end(N);
+ }
+};
+
+template <> struct GraphTraits<const SchedGraph*> {
+ typedef const SchedGraphNode NodeType;
+ typedef sg_succ_const_iterator ChildIteratorType;
+
+ static inline NodeType *getEntryNode(const SchedGraph *SG) {
+ return SG->getRoot();
+ }
+ static inline ChildIteratorType child_begin(NodeType *N) {
+ return succ_begin(N);
+ }
+ static inline ChildIteratorType child_end(NodeType *N) {
+ return succ_end(N);
+ }
+};
//************************ External Functions *****************************/
diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
index 9e2053b..7840a25 100644
--- a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
+++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
@@ -19,6 +19,7 @@
//**************************************************************************/
#include "SchedPriorities.h"
+#include "llvm/Support/PostOrderIterator.h"
SchedPriorities::SchedPriorities(const Method* method,
@@ -50,8 +51,7 @@
void
SchedPriorities::computeDelays(const SchedGraph* graph)
{
- sg_po_const_iterator poIter = sg_po_const_iterator::begin(graph->getRoot());
- sg_po_const_iterator poEnd = sg_po_const_iterator::end( graph->getRoot());
+ po_iterator<const SchedGraph*> poIter = po_begin(graph), poEnd =po_end(graph);
for ( ; poIter != poEnd; ++poIter)
{
const SchedGraphNode* node = *poIter;
diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.h b/lib/Target/SparcV9/InstrSched/SchedPriorities.h
index 909f4ed..81a2e6a 100644
--- a/lib/Target/SparcV9/InstrSched/SchedPriorities.h
+++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.h
@@ -25,6 +25,7 @@
#include "llvm/CodeGen/InstrScheduling.h"
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
#include "llvm/Target/MachineSchedInfo.h"
+#include <list>
class Method;
class MachineInstr;
diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
index e47c9d2..898dd28 100644
--- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
+++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
@@ -11,7 +11,7 @@
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
-
+#include "llvm/Support/PostOrderIterator.h"
/************************** Constructor/Destructor ***************************/
@@ -47,9 +47,9 @@
{
unsigned int POId = 0; // Reverse Depth-first Order ID
- cfg::po_const_iterator BBI = cfg::po_begin(Meth);
+ po_iterator<const Method*> BBI = po_begin(Meth);
- for( ; BBI != cfg::po_end(Meth) ; ++BBI, ++POId)
+ for( ; BBI != po_end(Meth) ; ++BBI, ++POId)
{
if(DEBUG_LV) cout << " For BB " << (*BBI)->getName() << ":" << endl ;
@@ -77,9 +77,9 @@
if(DEBUG_LV)
cout << endl << " After Backward Pass ..." << endl;
- cfg::po_const_iterator BBI = cfg::po_begin(Meth);
+ po_iterator<const Method*> BBI = po_begin(Meth);
- for( ; BBI != cfg::po_end(Meth) ; ++BBI)
+ for( ; BBI != po_end(Meth) ; ++BBI)
{
BBLiveVar* LVBB = BB2BBLVMap[*BBI];
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp
index 631db2c..446b95a 100644
--- a/lib/Transforms/Scalar/ADCE.cpp
+++ b/lib/Transforms/Scalar/ADCE.cpp
@@ -11,8 +11,8 @@
#include "llvm/Type.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/Support/STLExtras.h"
+#include "llvm/Support/DepthFirstIterator.h"
#include "llvm/Analysis/Writer.h"
-#include "llvm/CFG.h"
#include "llvm/iTerminators.h"
#include <set>
#include <algorithm>
@@ -90,7 +90,8 @@
// instructions live in basic blocks that are unreachable. These blocks will
// be eliminated later, along with the instructions inside.
//
- for (cfg::df_iterator BBI = cfg::df_begin(M), BBE = cfg::df_end(M);
+ for (df_iterator<Method*> BBI = df_begin(M),
+ BBE = df_end(M);
BBI != BBE; ++BBI) {
BasicBlock *BB = *BBI;
for (BasicBlock::iterator II = BB->begin(), EI = BB->end(); II != EI; ) {
diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp
index d349314..0372141 100644
--- a/lib/VMCore/Dominators.cpp
+++ b/lib/VMCore/Dominators.cpp
@@ -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,7 +60,7 @@
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);
@@ -110,7 +111,7 @@
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);
@@ -201,7 +202,7 @@
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 +224,17 @@
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 +243,11 @@
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 +265,21 @@
}
} 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();
diff --git a/lib/VMCore/SlotCalculator.cpp b/lib/VMCore/SlotCalculator.cpp
index 0ac371c..cac8f2e 100644
--- a/lib/VMCore/SlotCalculator.cpp
+++ b/lib/VMCore/SlotCalculator.cpp
@@ -20,7 +20,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/SymbolTable.h"
#include "llvm/Support/STLExtras.h"
-#include "llvm/CFG.h"
+#include "llvm/Support/DepthFirstIterator.h"
#include <algorithm>
#if 0
@@ -264,8 +264,8 @@
// the type itself is. This also assures us that we will not hit infinite
// recursion on recursive types...
//
- for (cfg::tdf_iterator I = cfg::tdf_begin(TheTy, true),
- E = cfg::tdf_end(TheTy); I != E; ++I)
+ for (df_iterator<const Type*> I = df_begin(TheTy, true),
+ E = df_end(TheTy); I != E; ++I)
if (*I != TheTy) {
// If we haven't seen this sub type before, add it to our type table!
const Type *SubTy = *I;