Generalize findNearestCommonDominator to work on post-dominators,
authorDan Gohman <gohman@apple.com>
Wed, 24 Mar 2010 00:22:24 +0000 (00:22 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 24 Mar 2010 00:22:24 +0000 (00:22 +0000)
based on a suggestion by Jochen Wilhelmy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99361 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/Dominators.h

index 1e94f304c9228a7ed0f60f7873d006b10fb2ce51..263862726e4ba6b14c21a07a6b982e0c47e5531c 100644 (file)
@@ -431,15 +431,16 @@ public:
   /// for basic block A and B. If there is no such block then return NULL.
   NodeT *findNearestCommonDominator(NodeT *A, NodeT *B) {
 
-    assert (!this->isPostDominator()
-            && "This is not implemented for post dominators");
     assert (A->getParent() == B->getParent()
             && "Two blocks are not in same function");
 
-    // If either A or B is a entry block then it is nearest common dominator.
-    NodeT &Entry  = A->getParent()->front();
-    if (A == &Entry || B == &Entry)
-      return &Entry;
+    // If either A or B is a entry block then it is nearest common dominator
+    // (for forward-dominators).
+    if (!this->isPostDominator()) {
+      NodeT &Entry  = A->getParent()->front();
+      if (A == &Entry || B == &Entry)
+        return &Entry;
+    }
 
     // If B dominates A then B is nearest common dominator.
     if (dominates(B, A))