<div dir="ltr"><br><br><div class="gmail_quote"><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">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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_-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< BranchProbabilityInfoWrapperPass >();</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><div>You can do</div><div> BPI.getEdgeProbability(Src, Dest).scale(BFI.getBlockProfileCount(Src));</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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><div>Correct.</div><div><br></div><div>David</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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>
_______________________________________________<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></div>