<div dir="ltr">There is no suggestion of redesign right now, but just more comments and documentation.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 4, 2017 at 1:50 PM, Dehao Chen via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">danielcdh added inline comments.<br>
<span class=""><br>
<br>
================<br>
Comment at: lib/Passes/PassBuilder.cpp:<wbr>552-553<br>
+  if (PGOOpt && !PGOOpt->SampleProfileFile.<wbr>empty()) {<br>
+    // Annotate sample profile right after early FPM to ensure freshness of<br>
+    // the debug info.<br>
+    MPM.addPass(<wbr>SampleProfileLoaderPass(<wbr>PGOOpt->SampleProfileFile));<br>
----------------<br>
</span><span class="">davidxl wrote:<br>
> chandlerc wrote:<br>
> > Above, you say that this is because SampleProfileLoaderPass needs to be here because it inlines calls. Here you talk about debug info freshness... Which is it?<br>
> ><br>
> > The debug info freshness makes plenty of sense to me. If SampleProfileLoaderPass is *doing inlining*, I find that deeply surprising and confusing. I'm not suggesting that we need to change the design of this right now, but I think the comment needs to be *really* clear because lots of other people will be surprised by this and I'd suggest a FIXME to revisit how this is structured. (Regardless of whether inlining makes sense here, I think it should *definitely* be separated from what appears to be a pass that merely annotates the IR from a profile.)<br>
> Should probably add a reference to the autofdo CGO 2016 paper which has detailed description of how autofdo's context senstive profile data is organized and the profile driven inline and branch profile annotation design.<br>
</span>Yes, we do invoke InlineFunction directly in SampleProfileLoader. There is a great many details about how we end up with this design in out cgo2016 paper. And I could explain to you in person if you like.<br>
<br>
The fundamental requirement is that we need to make the IR similar with the binary that is used for profiling, in order to annotate sample profile accurately.<br>
<br>
To get to that goal, we have choose to first inline inside the SampleProfileLoader before annotation. During the inlining we need to make the inline decision by interacting with SampleProfile interface. By doing this inside the SampleProfileLoader, we lock the use of SampleProfile interface within this file, instead of making it escape into the inliner.<br>
<br>
Alternatively, we could have a separate inliner pass to do this job. But that inliner pass need to read the SampleProfile too. So if we do that, we need to read the sample profile twice.<br>
<br>
I'm open to discuss about other design alternatives too.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D36333" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D36333</a><br>
<br>
<br>
<br>
</blockquote></div><br></div>