diff options
author | Chris Lattner <sabre@nondot.org> | 2005-11-18 07:27:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-11-18 07:27:33 +0000 |
commit | a35bef9db2298f9609d70fa9c898b76fede4a359 (patch) | |
tree | 49a39367a6f2cf5e2c8bc768c6c144126cf23037 /include/llvm/Analysis | |
parent | f124d5e5001e1c44cc72c4c51c63ca70b2ab190d (diff) | |
download | external_llvm-a35bef9db2298f9609d70fa9c898b76fede4a359.zip external_llvm-a35bef9db2298f9609d70fa9c898b76fede4a359.tar.gz external_llvm-a35bef9db2298f9609d70fa9c898b76fede4a359.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis')
-rw-r--r-- | include/llvm/Analysis/Dominators.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index 74ac293..9db52f6 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -306,16 +306,24 @@ public: 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; } |