diff options
-rw-r--r-- | include/llvm/Analysis/Dominators.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index d1fc5eb05a..6f2b2c03cf 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -185,6 +185,17 @@ protected: void updateDFSNumbers(); + /// Return the nearest common dominator of A and B. + BasicBlock *nearestCommonDominator(BasicBlock *A, BasicBlock *B) const { + ETNode *NodeA = getNode(A)->getETNode(); + ETNode *NodeB = getNode(B)->getETNode(); + + ETNode *Common = NodeA->NCA(NodeB); + if (!Common) + return NULL; + return Common->getData<BasicBlock>(); + } + /// dominates - Returns true iff this dominates N. Note that this is not a /// constant time operation! /// |