[LLVMdev] examine dominating relationships between basic blocks

Chris Lattner clattner at apple.com
Fri Jan 14 11:14:09 PST 2011


On Jan 14, 2011, at 8:06 AM, Chuck Zhao wrote:

> I am building code which needs to examine dominating relationships 
> between Basic Blocks.
> I searched the Programming Guide 
> (http://llvm.org/docs/ProgrammersManual.html#common), it mentioned 
> briefly that such details will be covered in the future.
> 
> So, I am tuning to the list and ask.
> 
> Say, I have BasicBlock * a, *b, and need to know whether a DOM b, (a 
> DOMi b, a DOMp b, a PostDOM b), etc.
> How can these be expressed?
> 
> Similar things,
> how can I find all BasicBlocks that a dominates, (DOM, DOMp, PostDOM, ...)
> 
> Browsing the source code, I seem to find things like DominatorFrontier, 
> DominatorTree, etc.
> But I have no clue how they can be used.

Hi Chuck,

You can get this by requiring the DominatorTree pass from your pass.  There are lots of examples of this in lib/Transforms/Scalar for example,

-Chris



More information about the llvm-dev mailing list