<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 11, 2015 at 11:07 AM, Diego Novillo via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">One aspect of this that I have not seen discussed is that middle-end instrumentation enables PGO optimizations to front-ends other than Clang.</div><div class="gmail_extra"><br></div><div class="gmail_extra">While I agree that FE instrumentation could be improved, it still requires every FE to implement essentially the same common functionality. Having PGO instrumentation generated in the middle-end, allows us every FE to automatically take advantage of PGO.</div></div></blockquote><div><br></div><div>This is a really good point, and I agree with it. We may have gotten off on the wrong foot since Rong's email focused so heavily on comparing with the frontend instrumentation. As far as I see it, Rong's proposal has a couple different parts:</div><div><br></div><div>1. Infrastructure for IR-level instrumentation-based PGO</div><div>2. Changes to the pass pipeline so that a hypothetical IR-level instrumentation-based PGO is more effective</div><div>3. MST algorithm with profile feedback for optimal placement of counter updates.</div><div><br></div><div>I think 1. is a no-brainer, if only so that all LLVM clients can benefit from PGO, and also (as you pointed out below) so that it can have an exclusive focus on performance. If it is sufficiently flexible, it may even make sense to restrict clang's frontend instrumentation-based profiling to non-performance stuff, and have clang directly interoperate with the IR-level PGO for performance-related PGO use cases, just like any other frontend would.</div><div><br></div><div>Philip and Sanjoy, out of curiosity do you guys use your own instrumentation placement for PGO? Is an IR-level PGO infrastructure upstream something you guys would be interested in?</div><div><br></div><div>I think that 2. is something that once we have 1. we will be able to evaluate better, but for now my opinion is that we should be able to make good progress without digging into that.</div><div><br></div><div>I think that 3. is a no-brainer if it provides a really significant win, but without 1. we can't really measure its effect in isolation. It also has a usability problem since it requires feeding in an existing profile for the *instrumented* build, but if the benefit is very significant this may be worth it for some users. We will probably be able to easily refactor 1. as needed into an MST approach that degrades gracefully to using static heuristics in the absence of real profile information, so is not a maintenance burden (maybe even helps by providing a good framework in which to develop effective static heuristics).</div><div><br></div><div>For the time being, I think we can avoid discussion of 2. and 3. until we have more of 1. working. So I think it would be most productive if we focus this discussion on 1.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra">Additionally, some of the overhead imposed by FE instrumentation is not really all that easy to get rid of. You end up duplicating functionality that is more naturally implemented in the middle end.</div></div></blockquote><div><br></div><div>Yeah, I was looking into a couple of other simple approaches and quickly found out that I was basically replicating much of the sort of logic that the inliner already has.</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra">I see the two approaches as supplementary, rather than complementary. One does not negate the other. Some of the optimizations we'd do in the FE, may hurt coverage. Instead, by instrumenting in the middle end, you can focus exclusively on performance (coverage be damned).</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Diego.</div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a> <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div>