<div dir="ltr"><div dir="ltr"><div>Thank You..</div><div>I want to implement following algorithm in LLVM pass..</div><div>1. Scan BB of CFG</div><div>2. If BB is not 1st entry block then</div><div>3.   If BB.predecessor block has instruction "conditional br" then</div><div>4.     dont print BB</div><div>5.   else</div><div>6.     print BB</div><div><br></div><div>Please help me...How to implement this algorithm in LLVM pass?<br></div><div>Thank You</div><div>Regards<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 11, 2019 at 9:12 PM Brian M. Rzycki <<a href="mailto:brzycki@gmail.com">brzycki@gmail.com</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 dir="ltr"><div dir="ltr"><div dir="ltr"><div><div><font face="monospace, monospace">Hello Hameeza,</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">If you have access to the dominator analysis (and the data is up-to-date) you can query if each block is dominated by the entry block of a function. I used this method to locate (and avoid) unreachable blocks at the beginning of the JumpThreading pass:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><a href="https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/Scalar/JumpThreading.cpp#L362" target="_blank">https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/Scalar/JumpThreading.cpp#L362</a></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">// JumpThreading must not processes blocks unreachable from entry. It's a</font></div><div><font face="monospace, monospace">// waste of compute time and can potentially lead to hangs.</font></div><div><font face="monospace, monospace">SmallPtrSet<BasicBlock *, 16> Unreachable;</font></div><div><font face="monospace, monospace">assert(DTU && "DTU isn't passed into JumpThreading before using it.");</font></div><div><font face="monospace, monospace">assert(DTU->hasDomTree() && "JumpThreading relies on DomTree to proceed.");</font></div><div><font face="monospace, monospace">DominatorTree &DT = DTU->getDomTree();</font></div><div><font face="monospace, monospace">for (auto &BB : F)</font></div><div><font face="monospace, monospace">  if (!DT.isReachableFromEntry(&BB))</font></div><div><font face="monospace, monospace">    Unreachable.insert(&BB);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">And later in the main for loop below (line 378):</font></div><div><font face="monospace, monospace">if (Unreachable.count(&BB))</font></div><div><font face="monospace, monospace">  continue;</font></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 11, 2019 at 12:29 AM hameeza ahmed via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">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 dir="ltr"><div>Hello,</div><div>I have code containing conditions and loops. Hence some BB execution are determined at run time depending on condition. Now I want to count only those BB that are always executed irrespective of condition result means reachable. and their execution is evident at compile time.<br></div><div><br></div><div>How to do this?</div><div><br></div><div>Please help</div><div><br></div><div>Thank You<br></div><div>Regards<br></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="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div></div>