[llvm-commits] [llvm] r99361 - /llvm/trunk/include/llvm/Analysis/Dominators.h

Dan Gohman gohman at apple.com
Tue Mar 23 17:22:25 PDT 2010


Author: djg
Date: Tue Mar 23 19:22:24 2010
New Revision: 99361

URL: http://llvm.org/viewvc/llvm-project?rev=99361&view=rev
Log:
Generalize findNearestCommonDominator to work on post-dominators,
based on a suggestion by Jochen Wilhelmy.

Modified:
    llvm/trunk/include/llvm/Analysis/Dominators.h

Modified: llvm/trunk/include/llvm/Analysis/Dominators.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Dominators.h?rev=99361&r1=99360&r2=99361&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/Dominators.h (original)
+++ llvm/trunk/include/llvm/Analysis/Dominators.h Tue Mar 23 19:22:24 2010
@@ -431,15 +431,16 @@
   /// 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))





More information about the llvm-commits mailing list