<div dir="ltr">Somehow, I didn't receive your email regarding you asking for the function's entry count but I'm able to see it on Google Groups.<div><br></div><div>The function's entry count is 1. My apologies for not having mentioned it before.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 15, 2018 at 3:46 PM, Malhar Thakkar <span dir="ltr"><<a href="mailto:cs13b1031@iith.ac.in" target="_blank">cs13b1031@iith.ac.in</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thank you so much for your response.<div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Wed, Aug 15, 2018 at 3:08 PM, Xinliang David Li <span dir="ltr"><<a href="mailto:xinliangli@gmail.com" target="_blank">xinliangli@gmail.com</a>></span> wrote:<br><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"><br><br><div class="gmail_quote"><span class="m_4338657512096116454gmail-"><div dir="ltr">On Wed, Aug 15, 2018 at 7:36 AM Malhar Thakkar 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">Hey all,<div><br></div><div>I have a piece of code (written in LLVM 2.8) which uses profiling results produced by ProfileInfo. It essentially computes the number of iterations performed by a loop from the profiling information available. The code snippet in my pass looks something like this.</div><div><br></div><div>



  <span></span>
  
  


<h2></h2>

<div class="m_4338657512096116454gmail-m_-7740094245048439705m_-6012055350149373409gmail-highlight" style="background:rgb(248,248,248)"><pre style="line-height:125%">  BasicBlock <span style="color:rgb(102,102,102)">*</span>header <span style="color:rgb(102,102,102)">=</span> loop<span style="color:rgb(102,102,102)">-></span>getHeader();
  ProfileInfo &pi = getAnalysis< ProfileInfo >();
  <span style="color:rgb(0,128,0);font-weight:bold">for</span>(pred_iterator i<span style="color:rgb(102,102,102)">=</span>pred_begin(header), e<span style="color:rgb(102,102,102)">=</span>pred_end(header); i<span style="color:rgb(102,102,102)">!=</span>e; <span style="color:rgb(102,102,102)">++</span>i)
  {
    BasicBlock <span style="color:rgb(102,102,102)">*</span>pred <span style="color:rgb(102,102,102)">=</span> <span style="color:rgb(102,102,102)">*</span>i;

    <span style="color:rgb(0,128,0);font-weight:bold">const</span> <span style="color:rgb(176,0,64)">double</span> edgeCount <span style="color:rgb(102,102,102)">=</span> <b>pi.getEdgeWeight</b>( ProfileInfo<span style="color:rgb(102,102,102)">::</span>Edge(pred,header) );
    <font color="#008000"><b>/* Some code */</b></font>
  }
</pre></div>


Now, since ProfileInfo has been deprecated and we have PGOInstrumentation passes along with BranchProbability and BlockFrequency, I wish to update the above snippet, in particular, obtaining the edge weights (highlighted in the code above) using the new tools.</div><div><br></div><div>In order to do that, I'm first generating edge count profile by the PGOInstrumentationGen pass and then interpreting the edge count profile with PGOInstrumentationUse.</div><div><br></div><div>In the original code, where I had </div><div><font face="monospace, monospace" style="font-weight:bold">au.addRequired< ProfileInfo >(), </font><font face="arial, helvetica, sans-serif">I now have </font><font face="monospace, monospace" style="font-weight:bold"> </font></div><div><font face="monospace, monospace" style="font-weight:bold"><br></font></div><div><font face="monospace, monospace"><b><div>au.addRequired< BlockFrequencyInfoWrapperPass >();</div><div>au.addRequired< BranchProbabilityInfoWrapperPa<wbr>ss >();</div><div><br></div></b></font></div><div>Now, I have the following queries.</div><div><ul><li>How do I use the edge count and branch weights data obtained using PGOInstrumentationUse in my pass and replace the <b><font face="monospace, monospace">getEdgeWeight()</font></b> from ProfileInfo?</li></ul></div></div></blockquote><div><br></div></span><div>You can do</div><div> BPI.getEdgeProbability(Src, Dest).scale(BFI.getBlockProfil<wbr>eCount(Src));</div></div></div></blockquote><div><br></div></span><div>I tried doing this but there are some semantic issues that I'm facing. There is a loop in my program which I know is a hot loop since it is the only loop inside the function main() and essentially, all the computations are performed within this function via function calls. However, when I perform <span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">getBlockProfileCount(Src) where Src is the preheader of the said loop, I find that it returns zero and upon further investigation, I found that the entry frequency for the function was 6148904414811 and the block frequency for the aforementioned preheader block was 6148904394768 and after performing udiv, since it is an integer division, getBlockProfileCount(Src) returned zero and hence, my code infers that it is not a hot loop when in fact it clearly is.</span> </div><div><br></div><div>Any suggestions on why this may be happening?</div><span class=""><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 class="gmail_quote"><span class="m_4338657512096116454gmail-"><div> </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><ul><li>If I call <b style="font-family:monospace,monospace">getBlockProfileCount() </b><font face="arial, helvetica, sans-serif">from the BlockFrequency pass, will that give me the data read during PGOInstrumentationUse or data based on static analysis? In other words, does the data obtained during PGOInstrumentationUse "propagate" to BlockFrequency and BranchProbability?</font></li></ul><div><font face="arial, helvetica, sans-serif"><br></font></div></div></div></blockquote></span><div>Correct.</div></div></div></blockquote></span><div>Just to confirm, when you say "correct", do you mean to say that the information in fact does get propagated to BlockFrequency and BranchProbability? If yes, how does the propagation take place? </div><div><br></div><div>Thank you.</div><div><br></div><div>Regards,</div><div>Malhar</div><span class=""><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 class="gmail_quote"><div><br></div><div>David</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_4338657512096116454gmail-"><div dir="ltr"><div><div><font face="arial, helvetica, sans-serif"></font></div></div><div><font face="arial, helvetica, sans-serif">Thank you.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Regards,</font></div><div><font face="arial, helvetica, sans-serif">Malhar</font></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=aY3MxM2IxMDMxQGlpdGguYWMuaW4%3D&type=zerocontent&guid=343de676-35f2-4e0e-9a4a-400954a5dfd9"><font color="#ffffff" size="1">ᐧ</font></div></span>
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>
</blockquote></span></div><br></div></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=aY3MxM2IxMDMxQGlpdGguYWMuaW4%3D&type=zerocontent&guid=e2b1fac8-1e90-4558-a9f1-dcf85ba172dd"><font color="#ffffff" size="1">ᐧ</font></div>
</blockquote></div><br></div></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=aY3MxM2IxMDMxQGlpdGguYWMuaW4%3D&type=zerocontent&guid=fd18ca4b-9afb-426a-ab8b-a9fe8fe05db0"><font color="#ffffff" size="1">ᐧ</font></div>