Access the Post Dominator tree

I’m trying to access the (post) dominator tree at the SelectionDAG phase to get the immediate post dominator block of a branch block. Would the post dominator tree be built at before that stage or does it occur after building the DAG? If it is, how can I get the post dominator tree of the specific block? I’m not able to find a specific function that returns the tree other than getNode but that works on a dominator tree.

Regards,
Kaarthik A.

I’m trying to access the (post) dominator tree at the SelectionDAG phase
to get the immediate post dominator block of a branch block. Would the post
dominator tree be built at before that stage or does it occur after
building the DAG? If it is, how can I get the post dominator tree of the
specific block? I’m not able to find a specific function that returns the
tree other than getNode but that works on a dominator tree.

Regards,
Kaarthik A.
_______________________________________________
LLVM Developers mailing list
llvm-dev@lists.llvm.org
llvm-dev Info Page

I'm assuming at SelectionDAG phase you're looking at LLVM IR post-dominator
tree (i.e. not machine one).

There are a few options.
You can state that post-dominace analysis is a prerequisite pass to your
pass in `getAnalysisUsage` and
later obtain it via `auto &PDT =
getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree();`

If it's not a hard requirement, you can check if it's already available
with `getAnalysisIfAvailable`.

Or you can construct it directly with `auto PDT = std::make_unique<

(*F);`

Once you have the post-dominator tree, you use the `dominates` member
function(s), they'll
return the post-dominance relation, despite the name.

Mind you, a number of convenience functions are not implemented for
post-dominator tree, look into
`lib/IR/Dominators.cpp` for inspiration how to implement them.

~chill