<div dir="ltr"><div dir="ltr"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 18, 2020 at 2:15 PM David Li via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.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">davidxl added inline comments.<br>
<br>
<br>
================<br>
Comment at: llvm/lib/Transforms/Instrumentation/CFGMST.h:110<br>
+    // If we want to instrument the entry count, lower the weight to 0.<br>
+    if (PGOInstrumentEntry)<br>
+      EntryWeight = 0;<br>
----------------<br>
Does this guarantee entry be instrumented?<br>
<br>
<br>
================<br>
Comment at: llvm/lib/Transforms/Instrumentation/CFGMST.h:147<br>
             Weight = BPI->getEdgeProbability(&*BB, TargetBB).scale(scaleFactor);<br>
+          if (Weight == 0)<br>
+            Weight++;<br>
----------------<br>
Is this the way to make sure entry is always instrumented?<br></blockquote><div><br></div><div>This together with the line above, will guarantee that fake edge the entry be the minimum. So it will not be the MST.</div><div>Yes. This is gonna guarantee that the entry will be instrumented.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
================<br>
Comment at: llvm/lib/Transforms/Instrumentation/CFGMST.h:292<br>
     computeMinimumSpanningTree();<br>
+    if (PGOInstrumentEntry && (AllEdges.size() > 1))<br>
+      std::iter_swap(std::move(AllEdges.begin()),<br>
----------------<br>
is this needed? Can somthing be done in CompputeMST without relying on weight trick?<br>
<br></blockquote><div>This is to make sure the index 0 be the entry BB. If we don't do this, that will be the last index.</div><div><br></div><div>I think this is a pretty clean way to implement -- if one knows how instrumentation is implemented. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
CHANGES SINCE LAST ACTION<br>
  <a href="https://reviews.llvm.org/D82123/new/" rel="noreferrer" target="_blank">https://reviews.llvm.org/D82123/new/</a><br>
<br>
<a href="https://reviews.llvm.org/D82123" rel="noreferrer" target="_blank">https://reviews.llvm.org/D82123</a><br>
<br>
<br>
<br>
</blockquote></div></div>