[llvm-dev] RFC: We should stop merging allocas in the inliner

Mehdi Amini via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 4 10:03:25 PDT 2016


> On Aug 4, 2016, at 10:00 AM, Chandler Carruth <chandlerc at gmail.com> wrote:
> 
> On Thu, Aug 4, 2016 at 9:56 AM Mehdi Amini via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
> 
>> On Aug 4, 2016, at 9:48 AM, Chandler Carruth via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>> 
>> On Thu, Aug 4, 2016 at 9:44 AM Joerg Sonnenberger via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>> On Mon, Aug 01, 2016 at 04:47:49AM +0000, Chandler Carruth via llvm-dev wrote:
>> > Chris added alloca merging in the inliner a looooong time ago, 2009. The
>> > reason he added it was because at the time we didn't do stack coloring and
>> > without it we had serious stack size problems in LLVM.
>> 
>> Do we have any way to hunt for stack size regressions? I've been hit by
>> some serious bugs in this area in GCC in the past and I would prefer to
>> not repeat that experience with LLVM.
>> 
>> 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?
>> 
>> 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.
> 
> Are these “clang tricks” some indications of weaknesses in LLVM on this aspect?
> 
> Depends on how you look at it. They're only enabled at O0.

Oh right, I missed that part. That’s fine then.

— 
Mehdi


> 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.
> 
> 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.
> 
> Within Clang there are somewhat more obvious repeated patterns that we can target for re-use.
> 
> 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.
>  
> 
>> Mehdi
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160804/091801b3/attachment.html>


More information about the llvm-dev mailing list