<div dir="ltr">So, for the record, I can't really remember why we did this rather than something else. Seems like it was probably a "quickest way to avoid non-linear compile time behavior" for a testcase. That said, I don't have the testcase anymore and have no way of duplicating it so I'm fairly ok with re-enabling them and running a compile time check on the existing test suite to check. My guess is that the "abuse" spoken of in the change isn't very common and we won't notice it though. That said, we'll probably get a better testcase and handle this in a bit more disciplined manner now that we know we care about lifetime intrinsics at O0.<div><br></div><div>-eric<br><div><br></div><div><br></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Aug 9, 2016 at 1:13 AM Chandler Carruth 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">So, tho story doesn't end here.<div><br></div><div>Fun thing. Clang at -O0, despite going to hackish lengths to re-use stack space in the frontend, explicitly disables the insertion of lifetime markers in the *always inliner* that runs at -O0. See r151430 to Clang which adds this.</div><div><br></div><div>However, that commit has ... very little information. Fortunately, it was paired with a change to LLVM in r151429 where the plumbing for this was added to the always inliner. In that commit, it was mentioned that the lifetime markers caused a, like, 100x slowdown in compile time. While Eric and Chad explained this as largely having to do with disabling fast-isel and doing more expensive selection-dag, given the number of bugs we've hit in the stack coloring I suspect that may also have played a part in the slowdown.</div><div><br></div><div>While I hope that we no longer have this kind of compile time penalty, at least the following need to happen to finally move on from this chapter of the inliner:</div><div><br></div><div>1) We need to re-enable lifetime intrinsics in the always inliner (and potentially disable alloca merging) to make sure they aren't crippling compile time any more.</div><div><br></div><div>2) See how bad the stack frame size regressions from nuking the alloca merging are in -O0 since that is the configuration where this is actually still doing something.</div><div><br></div><div>3) If the regressions in #2 are bad, do some work to turn on stack coloring (at least in a limited form) at -O0. I have no idea what is required here sadly. =/ This is not a part of the backend I know well.</div><div><br></div><div><br></div><div>I'm not going to have time to run with this in the very short term, but if anyone else is interested, I'm happy to provide pointers or advice.</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Aug 4, 2016 at 10:03 AM Mehdi Amini via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On Aug 4, 2016, at 10:00 AM, Chandler Carruth <<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>> wrote:</div><br class="m_-2638331930866608122m_-7977051686565586445Apple-interchange-newline"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote"><div dir="ltr">On Thu, Aug 4, 2016 at 9:56 AM Mehdi Amini via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Aug 4, 2016, at 9:48 AM, Chandler Carruth via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="m_-2638331930866608122m_-7977051686565586445m_5416903275673672482Apple-interchange-newline"><div><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Thu, Aug 4, 2016 at 9:44 AM Joerg Sonnenberger via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On Mon, Aug 01, 2016 at 04:47:49AM +0000, Chandler Carruth via llvm-dev wrote:<br>> Chris added alloca merging in the inliner a looooong time ago, 2009. The<br>> reason he added it was because at the time we didn't do stack coloring and<br>> without it we had serious stack size problems in LLVM.<br><br>Do we have any way to hunt for stack size regressions? I've been hit by<br>some serious bugs in this area in GCC in the past and I would prefer to<br>not repeat that experience with LLVM.<br></blockquote><div><br></div><div>My technique was to log the stack size and build a bunch of code, and then analyze the logs before and after. It seemed really effective though?</div><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">I also have some tests (sadly internal) that check stacksize is under some bound and those tend to serve is good indicators that something has gone badly wrong. For example, without the Clang tricks at -O0, we couldn't get their tests to pass.</span></div></div></div></div></blockquote></div><br></div><div style="word-wrap:break-word"><div>Are these “clang tricks” some indications of weaknesses in LLVM on this aspect?</div></div></blockquote><div><br></div><div>Depends on how you look at it. They're only enabled at O0.</div></div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div><div>Oh right, I missed that part. That’s fine then.</div><div><br></div><div>— </div></div></div><div style="word-wrap:break-word"><div><div>Mehdi</div></div></div><div style="word-wrap:break-word"><div><div><br></div><br><blockquote type="cite"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote"><div> It's essentially the lowest compile time cost way to re-use stack space in *highly* repeatative functions (like where you have macros stamping out 1000s of temporary std::string objects). Clang just keeps a freelist around of allocas and re-uses them.</div><div><br></div><div>We could always turn on some form of stack coloring at O0, but when we looked at it that would have been much harder to have match the compile time profile, and also harder to make survive debug info etc.</div><div><br></div><div>Within Clang there are somewhat more obvious repeated patterns that we can target for re-use.</div><div><br></div><div>At least, this is my memory from the discussion with Richard Smith when he implemented this. =] He may want to provide more details or correct my memory of things.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>— </div></div><div style="word-wrap:break-word"><div>Mehdi</div><div><br></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="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></blockquote></div></div></div></blockquote></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="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>
</blockquote></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="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>
</blockquote></div></div></div>