<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 19, 2021 at 1:31 PM Alex Lorenz via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-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">Hi,<br>
<br>
> On May 19, 2021, at 1:18 PM, Reid Kleckner via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
> <br>
> Hi folks,<br>
> <br>
> I wanted to make some improvements to code coverage, which uses frontend profile instrumentation. Is anyone still using frontend PGO for optimization (not coverage), or has everyone moved to IR PGO for that?<br>
> <br>
> Here are the existing modes as I understand them:<br>
> <br>
> 1. Frontend PGO: -fprofile-instr-generate / use. Code in clang/lib/CodeGen/CodeGenPGO.cpp inserts PGO counter update intrinsics. This happens before optimization. This is very source directed.<br>
> <br>
> 2. Coverage: -fprofile-instr-generate -fcoverage-mapping. This is basically frontend PGO, plus some extra coverage mapping data to map from counters back to precise source locations.<br>
> <br>
> 3. IR PGO: -fprofile-generate. The LLVM IR pass llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp is responsible for inserting calls to the counter update intrinsics at some specific point in the optimization pipeline. IIUC, this is done after the "pre-inliner" pass and other simplification passes so that there are fewer counter updates and a bit more precision.<br>
> <br>
> 4. Context sensitive PGO: -fcs-profile-generate. This is basically the same as IR PGO, except it happens after regular inlining, so you can use it as a "second round" of PGO: use IR PGO first, get profile guided inlinings, profile again, and use that to influence code layout or further inlining.<br>
> <br>
> ---<br>
> <br>
> Is anyone using the first mode, frontend PGO, or has everyone migrated to IR PGO already? It seems to me that the main use case for frontend PGO is really just coverage, and we should consider deprecating frontend PGO. In Chrome, we accidentally started using frontend PGO instead of IR PGO, and found that IR PGO was better.<br>
> <br>
<br>
Yes, we use the frontend PGO in Apple clang in Xcode. I’m curious though, what kind of improvements did you see with IR PGO?<br></blockquote><div><br></div><div><a class="gmail_plusreply" id="plusReplyChip-0" href="mailto:vsk@apple.com" tabindex="-1">+Vedant Kumar</a> <br></div><div><br></div><div>Any other reason you are using frontend PGO for performance?  IR PGO has other advantages as well: 1) better performance in training run; 2) better value profiling support; and 3) smaller raw profile data size.</div><div><br></div><div>Deprecating frontend-PGO (and making it for coverage testing only) would be desirable as Reid said.</div><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">
<br>
> I'm asking because I would like to make code coverage builds faster and smaller, and supporting PGO with the same codepaths makes that complicated.<br>
> <br>
> Reid<br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>