1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 11:33:24 +02:00

Generalize findNearestCommonDominator to work on post-dominators,

based on a suggestion by Jochen Wilhelmy.

llvm-svn: 99361
This commit is contained in:
Dan Gohman 2010-03-24 00:22:24 +00:00
parent e42b80792e
commit 7e7698c5a1

View File

@ -431,15 +431,16 @@ public:
/// 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.
// 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))