From 259e6cf1911a91ed80f77b132d1509fd0581a4a1 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Thu, 7 Jun 2007 18:39:40 +0000 Subject: [PATCH] Add BasicBlock level dominates(A,B) interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37493 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/Dominators.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index 87ea6c1651d..96f3f223dc1 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -170,11 +170,16 @@ protected: } void updateDFSNumbers(); + /// dominates - Returns true iff this dominates N. Note that this is not a /// constant time operation! /// inline bool dominates(const DomTreeNode *A, DomTreeNode *B) { - if (B == A) return true; // A node trivially dominates itself. + if (B == A) + return true; // A node trivially dominates itself. + + if (A == 0 || B == 0) + return false; ETNode *NodeA = A->getETNode(); ETNode *NodeB = B->getETNode(); @@ -192,7 +197,14 @@ protected: //return NodeB->DominatedBySlow(NodeA); return dominatedBySlowTreeWalk(A, B); } - + + inline bool dominates(BasicBlock *A, BasicBlock *B) { + if (A == B) + return true; + + return dominates(getNode(A), getNode(B)); + } + //===--------------------------------------------------------------------===// // API to update (Post)DominatorTree information based on modifications to // the CFG...