Expand the pass to unify all of the unwind blocks as well
[oota-llvm.git] / include / llvm / Support / CFG.h
index 8b68627201dac8c963f9285063dd4010766b4e45..aab0db9712b9f1aeefca7dd80dd148a64dd8e18c 100644 (file)
@@ -10,7 +10,6 @@
 
 #include "Support/GraphTraits.h"
 #include "llvm/Function.h"
-#include "llvm/BasicBlock.h"
 #include "llvm/InstrTypes.h"
 #include "Support/iterator"
 
@@ -28,8 +27,7 @@ public:
   typedef typename super::pointer pointer;
   
   inline void advancePastConstants() {
-    // TODO: This is bad
-    // Loop to ignore constant pool references
+    // Loop to ignore non terminator uses (for example PHI nodes)...
     while (It != BB->use_end() && !isa<TerminatorInst>(*It))
       ++It;
   }
@@ -44,7 +42,7 @@ public:
   
   inline pointer operator*() const { 
     assert(It != BB->use_end() && "pred_iterator out of range!");
-    return cast<Instruction>(*It)->getParent(); 
+    return cast<TerminatorInst>(*It)->getParent(); 
   }
   inline pointer *operator->() const { return &(operator*()); }
   
@@ -220,10 +218,20 @@ template <> struct GraphTraits<Inverse<const BasicBlock*> > {
 //
 template <> struct GraphTraits<Function*> : public GraphTraits<BasicBlock*> {
   static NodeType *getEntryNode(Function *F) { return &F->getEntryNode(); }
+
+  // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
+  typedef Function::iterator nodes_iterator;
+  static nodes_iterator nodes_begin(Function *F) { return F->begin(); }
+  static nodes_iterator nodes_end  (Function *F) { return F->end(); }
 };
 template <> struct GraphTraits<const Function*> :
   public GraphTraits<const BasicBlock*> {
   static NodeType *getEntryNode(const Function *F) { return &F->getEntryNode();}
+
+  // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
+  typedef Function::const_iterator nodes_iterator;
+  static nodes_iterator nodes_begin(const Function *F) { return F->begin(); }
+  static nodes_iterator nodes_end  (const Function *F) { return F->end(); }
 };