[llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h

Chris Lattner lattner at cs.uiuc.edu
Thu Nov 17 23:27:45 PST 2005



Changes in directory llvm/include/llvm/Analysis:

Dominators.h updated: 1.49 -> 1.50
---
Log message:

Fix the dominates method to return true if the two nodes are the same.  Add
a new properlyDominates method to do what the old one did.


---
Diffs of the changes:  (+12 -4)

 Dominators.h |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)


Index: llvm/include/llvm/Analysis/Dominators.h
diff -u llvm/include/llvm/Analysis/Dominators.h:1.49 llvm/include/llvm/Analysis/Dominators.h:1.50
--- llvm/include/llvm/Analysis/Dominators.h:1.49	Thu Apr 21 15:16:31 2005
+++ llvm/include/llvm/Analysis/Dominators.h	Fri Nov 18 01:27:33 2005
@@ -306,16 +306,24 @@
     inline Node *getIDom() const { return IDom; }
     inline const std::vector<Node*> &getChildren() const { return Children; }
 
-    /// dominates - Returns true iff this dominates N.  Note that this is not a
-    /// constant time operation!
+    /// properlyDominates - Returns true iff this dominates N and this != N.
+    /// Note that this is not a constant time operation!
     ///
-    inline bool dominates(const Node *N) const {
+    bool properlyDominates(const Node *N) const {
       const Node *IDom;
       while ((IDom = N->getIDom()) != 0 && IDom != this)
-      N = IDom;   // Walk up the tree
+        N = IDom;   // Walk up the tree
       return IDom != 0;
     }
 
+    /// dominates - Returns true iff this dominates N.  Note that this is not a
+    /// constant time operation!
+    ///
+    inline bool dominates(const Node *N) const {
+      if (N == this) return true;  // A node trivially dominates itself.
+      return properlyDominates(N);
+    }
+    
   private:
     inline Node(BasicBlock *BB, Node *iDom) : TheBB(BB), IDom(iDom) {}
     inline Node *addChild(Node *C) { Children.push_back(C); return C; }






More information about the llvm-commits mailing list