<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, Mar 1, 2021 at 11:53 AM Fangrui Song 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">MaskRay added a comment.<br>
<br>
In D97585#2595131 <<a href="https://reviews.llvm.org/D97585#2595131" rel="noreferrer" target="_blank">https://reviews.llvm.org/D97585#2595131</a>>, @rnk wrote:<br>
<br>
> Wait, are you telling me that `__profd/__profc` data can participate in linker GC, and that is not a problem?<br>
<br>
Yes on ld.lld, since D96636 <<a href="https://reviews.llvm.org/D96636" rel="noreferrer" target="_blank">https://reviews.llvm.org/D96636</a>> .  The GC is more useful with D96757 <<a href="https://reviews.llvm.org/D96757" rel="noreferrer" target="_blank">https://reviews.llvm.org/D96757</a>>, which moved metadata sections which were not within a `comdat any` into a `comdat noduplicates` group.<br>
<br>
> I have actually had to optimize the processing of `/INCLUDE:` directives for COFF (D78845 <<a href="https://reviews.llvm.org/D78845" rel="noreferrer" target="_blank">https://reviews.llvm.org/D78845</a>>), because I assumed that it was critical that `__profd` be treated as a GC root.<br>
<br>
Yes. I think getting rid of the local linkage limitation is important for COFF GC.<br>
<br>
> But, on ELF, they were never GC roots, and coverage/PGO has worked just fine there.<br>
<br>
Yes. For some sections (`__llvm_prf_nm` `__llvm_prf_vnds`), they work just because linkers have such a rule:<br>
<br>
> __start_/__stop_ references from a live input section retains all non-SHF_LINK_ORDER non-SHF_GROUP C identifier name sections.<br>
<br>
`-z start-stop-gc` can drop the rule, so we need D97649 <<a href="https://reviews.llvm.org/D97649" rel="noreferrer" target="_blank">https://reviews.llvm.org/D97649</a>> for robustness.<br>
<br>
That said, I am still not very confident with GCness for the compressed `__llvm_prf_nm`. I think for PGO it is optional, so whether we retain or discard it probably does not matter much. </blockquote><div><br></div><div><div class="gmail_default" style="font-family:monospace;font-size:small;color:rgb(0,0,0)">That is not correct -- names are important for symbol resolution for indirect call promotion purposes in PGO.</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><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">For coverage mapping it might be a problem.<br>
But this patch and D97649 <<a href="https://reviews.llvm.org/D97649" rel="noreferrer" target="_blank">https://reviews.llvm.org/D97649</a>> do not change the status quo.<br>
<br>
> So, really, all along, llvm.used was only being used to block LLVM IPO transforms like globalopt, not to establish a GC root. And, as you point out, we don't get the GC root behavior for internal `__profd/__profc` globals, and coverage/PGO seems to work fine.<br>
<br>
<br>
<br>
> What about MachO? Should all platforms not treat __profd as a GC root?<br>
<br>
Since MachO does not have comdat. I think it has to be conservative and treats every metadata section GC roots (`llvm.used`).<br>
<br>
All binary formats with ELF section group compatible semantics ("if section A in a section group is retained, all members in the group are retained as well") should be able to use `llvm.compiler.used`.<br>
I believe COFF can do it, but as you said, `/INCLUDE:` needs fixes to support local linkage `GlobalObject`s.<br>
<br>
<br>
Repository:<br>
  rG LLVM Github Monorepo<br>
<br>
CHANGES SINCE LAST ACTION<br>
  <a href="https://reviews.llvm.org/D97585/new/" rel="noreferrer" target="_blank">https://reviews.llvm.org/D97585/new/</a><br>
<br>
<a href="https://reviews.llvm.org/D97585" rel="noreferrer" target="_blank">https://reviews.llvm.org/D97585</a><br>
<br>
</blockquote></div></div>