Add BasicBlock level dominates(A,B) interface.
authorDevang Patel <dpatel@apple.com>
Thu, 7 Jun 2007 18:39:40 +0000 (18:39 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 7 Jun 2007 18:39:40 +0000 (18:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37493 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/Dominators.h

index 87ea6c1651dc7e8807ae9653095888e8e4de0e7e..96f3f223dc1afa6a7a3934522fad5ccf8b678d98 100644 (file)
@@ -170,11 +170,16 @@ protected:
   }
 
   void updateDFSNumbers();  
+
   /// dominates - Returns true iff this dominates N.  Note that this is not a
   /// constant time operation!
   ///
   inline bool dominates(const DomTreeNode *A, DomTreeNode *B) {
-    if (B == A) return true;  // A node trivially dominates itself.
+    if (B == A) 
+      return true;  // A node trivially dominates itself.
+
+    if (A == 0 || B == 0)
+      return false;
 
     ETNode *NodeA = A->getETNode();
     ETNode *NodeB = B->getETNode();
@@ -192,7 +197,14 @@ protected:
     //return NodeB->DominatedBySlow(NodeA);
     return dominatedBySlowTreeWalk(A, B);
   }
-  
+
+  inline bool dominates(BasicBlock *A, BasicBlock *B) {
+    if (A == B) 
+      return true;
+    
+    return dominates(getNode(A), getNode(B));
+  }
+
   //===--------------------------------------------------------------------===//
   // API to update (Post)DominatorTree information based on modifications to
   // the CFG...