<div dir="ltr"><div style="font-family:monospace,monospace;font-size:small" class="gmail_default"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">O<span class="gmail_default" style="font-family:monospace,monospace;font-size:small"></span>n Wed, Oct 16, 2019 at 6:43 PM Kaarthik Alagapan via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div>
<div name="messageBodySection">
<div dir="auto">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.</div>
</div>
<div name="messageSignatureSection"><br>
<div dir="auto">Regards,</div>
<div dir="auto">Kaarthik A.</div>
</div>
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div><div style="font-family:monospace,monospace;font-size:small" class="gmail_default"><div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">I'm assuming at SelectionDAG phase you're looking at LLVM IR post-dominator tree (i.e. not machine one).</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">There are a few options.</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">You can state that post-dominace analysis is a prerequisite pass to your pass in `getAnalysisUsage` and</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">later obtain it via `auto &PDT = getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree();`</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">If it's not a hard requirement, you can check if it's already available with `getAnalysisIfAvailable`.</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">Or you can construct it directly with <span class="gmail-n">`auto PDT</span> <span class="gmail-o">=</span> <span class="gmail-n">std</span><span class="gmail-o">::</span><span class="gmail-n">make_unique</span><span class="gmail-o"><</span><span class="gmail-n">PostDominatorTree</span><span class="gmail-o">></span><span class="gmail-p">(</span><span class="gmail-o">*</span><span class="gmail-n">F</span><span class="gmail-p">);`</span></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">Once you have the post-dominator tree, you use the `dominates` member function(s), they'll</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">return the post-dominance relation, despite the name.</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">Mind you, a number of convenience functions are not implemented for post-dominator tree, look into</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">`lib/IR/Dominators.cpp` for inspiration how to implement them.<br></div></div></div><div style="font-family:monospace,monospace;font-size:small" class="gmail_default"><br></div><div style="font-family:monospace,monospace;font-size:small" class="gmail_default">~chill</div><div style="font-family:monospace,monospace;font-size:small" class="gmail_default"><br></div><div style="font-family:monospace,monospace;font-size:small" class="gmail_default">--</div><div style="font-family:monospace,monospace;font-size:small" class="gmail_default">Compiler scrub, Arm.<br></div><div style="font-family:monospace,monospace;font-size:small" class="gmail_default"><br></div></div>