[LLVMdev] findNearestCommonDominator for PostDominatorTree

Jochen Wilhelmy j.wilhelmy at arcor.de
Sun Mar 7 02:09:28 PST 2010


Hi!

I'd like to find the point where the control flow joins after a branch.

e.g. if I have the following function

if (a < b)
    foo1();
else
    foo2();
bar();

Then the control flow splits at the basic block containing a < b with
a branch as terminator instruction. At the basic block with bar() the 
control
flow joins again (at first my control flow graph does not have loops).

I would think I have to calculate the post dominator tree and then call
findNearestCommonDominator on the two branches, but this function
is missing. Does this have a reason? I would think it's just

inline BasicBlock *findNearestCommonDominator(BasicBlock *A, BasicBlock 
*B) {
    return DT->findNearestCommonDominator(A, B);
  }

like for llvm::DominatorTree. Is it possible to add it?

The method of finding the control flow join should also work for this case:

if (a < b)
{
    foo1();
    if (c < d) goto label;
    foo2();
}
else
{
    foo3();
label:
    foo4();
}
bar();

- Jochen




More information about the llvm-dev mailing list