<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:monospace;font-size:small;color:#000000"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 14, 2021 at 11:28 AM Ellis Hoag 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">ellis added a comment.<br>
<br>
<br>
<br>
In D104060#2815939 <<a href="https://reviews.llvm.org/D104060#2815939" rel="noreferrer" target="_blank">https://reviews.llvm.org/D104060#2815939</a>>, @davidxl wrote:<br>
<br>
> MIP has achieved great size reduction for instrumented binary. My<br>
> understanding the savings are mainly from the following:<br>
><br>
> 1. Smaller counter size (1 byte or 4 byte instead of 8 byte for IR PGO)<br>
> 2. extractable per function metadata (mipmap). Using this technique may<br>
><br>
> increase object file size more (due to extra relocations), but will reduce<br>
> executable size.<br>
<br>
That is correct. For function coverage MIP inject only one `movb` instruction in x86 so that the total overhead for every function is 1 byte of global data + 7 bytes of text.<br>
<br>
> I don't understand (in block coverage mode) how the .text size can be<br>
> reduced. I have not looked at the patch in detail, but the test case shows<br>
> that the counter update is simply a 'movb 0, $counter' even in non-coverage<br>
> mode, is that expected?<br>
<br>
Let me try to clear something up. The size tests I ran in <a href="https://gist.github.com/ellishg/92a68cf82bfdeccd10225154425edc69" rel="noreferrer" target="_blank">https://gist.github.com/ellishg/92a68cf82bfdeccd10225154425edc69</a> were for function coverage only and block coverage disabled. For block coverage, we inject a single `movb` instruction and another global byte for each basic block so the size overhead is very similar to function coverage. Can you point me to the test case you are referring to?<br></blockquote><div><br></div><div><br></div><div><div class="gmail_default" style="font-family:monospace;font-size:small;color:rgb(0,0,0)">I mistyped in my previous reply. I meant that I don't expect the text size to be reduced much in the block counting mode (not coverage mode) with MIP. I understand this is not available in MIP right now, but comparing 'function coverage mode' with 'block counting mode' is apples to oranges.</div><div class="gmail_default" style="font-family:monospace;font-size:small;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:monospace;font-size:small;color:rgb(0,0,0)">What I am getting at is that if there are not any size reduction techniques that fundamentally must be done in MIR level, we should try to incorporate the features into the common profiling infrastructure.  For instance, introducing coverage mode (both function and block level) in IRPGO.</div><div class="gmail_default" style="font-family:monospace;font-size:small;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:monospace;font-size:small;color:rgb(0,0,0)">This also allows further size optimizations in the common infra in the future. For instance, using one bit per block in coverage mode etc.</div><div class="gmail_default" style="font-family:monospace;font-size:small;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:monospace;font-size:small;color:rgb(0,0,0)">David</div><br></div><div><div class="gmail_default" style="font-family:monospace;font-size:small;color:rgb(0,0,0)"></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">
<br>
> I think 2) is something worth introducing to IRPGO under a flag.<br>
><br>
> David<br>
<br>
<br>
<br>
<br>
Repository:<br>
  rG LLVM Github Monorepo<br>
<br>
CHANGES SINCE LAST ACTION<br>
  <a href="https://reviews.llvm.org/D104060/new/" rel="noreferrer" target="_blank">https://reviews.llvm.org/D104060/new/</a><br>
<br>
<a href="https://reviews.llvm.org/D104060" rel="noreferrer" target="_blank">https://reviews.llvm.org/D104060</a><br>
<br>
</blockquote></div></div>