<div dir="ltr">Hi,<div><br></div><div><div>I think the idea is worth experimenting as long as the experiment does not affect the production code very much.</div><div><br></div><div>We will most likely need a size cap.  I think we have yet to see whether we can completely replace the profile-driven CGSCC inliner or use the priority-based inliner for hot paths with low-priority call sites left for the CGSCC inliner to process.<br></div></div><div><br></div><div>I am curious how many cases we can catch that are typical limitations of the CGSCC inliner.  By that, I mean cases where, given A->B->C, inlining C into B prevents B from being inlined into A, but inlining the original B into A is more profitable.  Hot code with lukewarm slow paths are pretty common like std::vector<T>::push_back, which occasionally allocates memory.<br></div><div><br></div><div>Kazu Hirata</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 30, 2021 at 3:49 PM Wenlei He via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-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">





<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="gmail-m_9023885150520796487WordSection1">
<p class="MsoNormal">This is a topic that has been discussed a few times in the past. Currently CGSCC inliner doesn’t use a size/growth cap, so the value of call site prioritization is questionable as we’re going to inline everything deemed beneficial anyways.
 But prioritization would be helpful for top-down inliner that needs a size/growth cap.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Under Sample PGO, we now have a top-down inliner in sample loader already to handle most of the hot inlining (<a href="https://reviews.llvm.org/D70655" target="_blank">https://reviews.llvm.org/D70655</a>,
<a href="https://reviews.llvm.org/D82919" target="_blank">https://reviews.llvm.org/D82919</a>). Sample loader is a module pass, so the inliner there is module inliner too. And with the new CSSPGO (<a href="https://lists.llvm.org/pipermail/llvm-dev/2020-August/144101.html" target="_blank">https://lists.llvm.org/pipermail/llvm-dev/2020-August/144101.html</a>),
 we’ve changed to use a call site prioritized top-down inliner for sample loader as the inlining there is no longer limited to inline replay (<a href="https://reviews.llvm.org/D94001" target="_blank">https://reviews.llvm.org/D94001</a>). The sample loader inliner is probably
 closer to what you’re planning to do, but such top-down call site prioritization would be most effective when context-sensitive profile is available so inliner can do proper specialization along different inline context.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">+<a id="gmail-m_9023885150520796487OWAAM0BD1DF7E9920EB4CB455F647BA8AAB2A" href="mailto:hoy@fb.com" target="_blank"><span style="font-family:Calibri,sans-serif;text-decoration:none">@Hongtao Yu</span></a>
<a id="gmail-m_9023885150520796487OWAAM7420B9583839DA4A835D9741216171CD" href="mailto:wlei@fb.com" target="_blank"><span style="font-family:Calibri,sans-serif;text-decoration:none">@Lei Wang</span></a><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal">Wenlei<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>> on behalf of David Blaikie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Date: </b>Monday, August 30, 2021 at 9:52 AM<br>
<b>To: </b>Liqiang Tao <<a href="mailto:taolq926@gmail.com" target="_blank">taolq926@gmail.com</a>>, Chandler Carruth <<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>>, Arthur Eubanks <<a href="mailto:aeubanks@google.com" target="_blank">aeubanks@google.com</a>>, David Li <<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.com</a>><br>
<b>Cc: </b>llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject: </b>Re: [llvm-dev] [RFC] Add a module inliner<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal">+a couple of folks who might have some thoughts/ideas here<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Tue, Aug 24, 2021 at 8:57 AM Liqiang Tao via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<p style="margin-right:0in;margin-bottom:9.6pt;margin-left:0in;box-sizing:border-box;line-height:inherit;white-space:pre-wrap">
<span style="font-size:12pt;font-family:"Open Sans",sans-serif;color:rgb(51,51,51)">In my GSoC 2021, my goal is to evaluate the value of different callsite visiting orderings, which is inspired by paper[1][2]. I've already enabled doing such an exploration within
 the constraints of the current SCC inliner (</span><a href="https://reviews.llvm.org/D104028" target="_blank"><span style="font-size:12pt;font-family:"Open Sans",sans-serif">https://reviews.llvm.org/D104028</span></a><span style="font-size:12pt;font-family:"Open Sans",sans-serif;color:rgb(51,51,51)">).
 Exploring more advanced callsite orderings is not possible with the current SCC inliner. The current SCC inliner runs on each SCC in a bottom-up traversal, which means that the inline order is limited to a bottom-up order.
<u></u><u></u></span></p>
<p style="margin-right:0in;margin-bottom:9.6pt;margin-left:0in;box-sizing:border-box;line-height:inherit;white-space:pre-wrap">
<span style="font-size:12pt;font-family:"Open Sans",sans-serif;color:rgb(51,51,51)">To address this limitation, I would like to add a module inliner, which processes all call sites in a given module at a time instead of a given SCC. This gives us flexibility on
 the order in which we process call sites.<u></u><u></u></span></p>
<p style="margin-right:0in;margin-bottom:9.6pt;margin-left:0in;box-sizing:border-box;line-height:inherit;white-space:pre-wrap">
<span style="font-size:12pt;font-family:"Open Sans",sans-serif;color:rgb(51,51,51)">The module inliner would be disabled by default, to minimize code churn to the existing codebase and make it easier to remove it. Also, to avoid unnecessary abstractions, which
 would complicate the existing codebase, some code is copied from SCC inliner. Lastly, to foster collaboration, I would propose landing it in trunk rather than a branch.<u></u><u></u></span></p>
<p style="margin-right:0in;margin-bottom:9.6pt;margin-left:0in;box-sizing:border-box;line-height:inherit;white-space:pre-wrap">
<span style="font-size:12pt;font-family:"Open Sans",sans-serif;color:rgb(51,51,51)">Best wishes,<u></u><u></u></span></p>
<p style="margin-right:0in;margin-bottom:9.6pt;margin-left:0in;box-sizing:border-box;line-height:inherit;white-space:pre-wrap">
<span style="font-size:12pt;font-family:"Open Sans",sans-serif;color:rgb(51,51,51)">Liqiang Tao<u></u><u></u></span></p>
<p style="margin-right:0in;margin-bottom:9.6pt;margin-left:0in;box-sizing:border-box;line-height:inherit;white-space:pre-wrap">
<span style="font-size:12pt;font-family:"Open Sans",sans-serif;color:rgb(51,51,51)">---- [1] Aleksandar Prokopec, Gilles Duboscq, David Leopoldseder, and Thomas Würthinger. 2019. An optimization-driven incremental inline substitution algorithm for just-in-time
 compilers. In Proceedings of the 2019 IEEE/ACM International Symposium on Code Generation and Optimization (CGO 2019). [2] Dhruva R. Chakrabarti and Shin-Ming Liu. 2006. Inline Analysis: Beyond Selection Heuristics. In Proceedings of the International Symposium
 on Code Generation and Optimization (CGO '06). <u></u><u></u></span></p>
</div>
<p class="MsoNormal">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><u></u><u></u></p>
</blockquote>
</div>
</div>
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>