Add new method - nearestCommonDominator().
authorDevang Patel <dpatel@apple.com>
Fri, 8 Jun 2007 00:21:17 +0000 (00:21 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 8 Jun 2007 00:21:17 +0000 (00:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37508 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/Dominators.h

index d1fc5eb05a93ddd3f1bf34cbd81d18804b735248..6f2b2c03cfbcab4bc0cf8d49f7f45bca342a4978 100644 (file)
@@ -185,6 +185,17 @@ protected:
 
   void updateDFSNumbers();  
 
+  /// Return the nearest common dominator of A and B.
+  BasicBlock *nearestCommonDominator(BasicBlock *A, BasicBlock *B) const  {
+    ETNode *NodeA = getNode(A)->getETNode();
+    ETNode *NodeB = getNode(B)->getETNode();
+    
+    ETNode *Common = NodeA->NCA(NodeB);
+    if (!Common)
+      return NULL;
+    return Common->getData<BasicBlock>();
+  }
+  
   /// dominates - Returns true iff this dominates N.  Note that this is not a
   /// constant time operation!
   ///