public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <richard.guenther@gmail.com>
To: Xinliang David Li <davidxl@google.com>
Cc: Mark Heffernan <meheff@google.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [google] pessimize stack accounting during inlining
Date: Wed, 08 Jun 2011 09:11:00 -0000	[thread overview]
Message-ID: <BANLkTi=-Xg9AY2yNw-MgAQ==6RuuGxiyPg@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=70RMg26xoi=ORR_4ZV50xEfjSrJUq+chZR1uOWnJXfg@mail.gmail.com>

On Wed, Jun 8, 2011 at 1:36 AM, Xinliang David Li <davidxl@google.com> wrote:
> Ok for google/main.   A good candidate patch for trunk too.

Well, it's still not a hard limit as we can't tell how many spill slots
or extra call argument or return value slots we need.

Richard.

> Thanks,
>
> David
>
> On Tue, Jun 7, 2011 at 4:29 PM, Mark Heffernan <meheff@google.com> wrote:
>> This patch pessimizes stack accounting during inlining.  This enables
>> setting a firm stack size limit (via parameters "large-stack-frame" and
>> "large-stack-frame-growth").  Without this patch the inliner is overly
>> optimistic about potential stack reuse resulting in actual stack frames much
>> larger than the parameterized limits.
>> Internal benchmarks show minor performance differences with non-fdo and
>> lipo, but overall neutral.  Tested/bootstrapped on x86-64.
>> Ok for google-main?
>> Mark
>>
>> 2011-06-07  Mark Heffernan  <meheff@google.com>
>>         * cgraph.h (cgraph_global_info): Remove field.
>>         * ipa-inline.c (cgraph_clone_inlined_nodes): Change
>>         stack frame computation.
>>         (cgraph_check_inline_limits): Ditto.
>>         (compute_inline_parameters): Remove dead initialization.
>>
>> Index: gcc/cgraph.h
>> ===================================================================
>> --- gcc/cgraph.h        (revision 174512)
>> +++ gcc/cgraph.h        (working copy)
>> @@ -136,8 +136,6 @@ struct GTY(()) cgraph_local_info {
>>  struct GTY(()) cgraph_global_info {
>>    /* Estimated stack frame consumption by the function.  */
>>    HOST_WIDE_INT estimated_stack_size;
>> -  /* Expected offset of the stack frame of inlined function.  */
>> -  HOST_WIDE_INT stack_frame_offset;
>>
>>    /* For inline clones this points to the function they will be
>>       inlined into.  */
>> Index: gcc/ipa-inline.c
>> ===================================================================
>> --- gcc/ipa-inline.c    (revision 174512)
>> +++ gcc/ipa-inline.c    (working copy)
>> @@ -229,8 +229,6 @@ void
>>  cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate,
>>                             bool update_original)
>>  {
>> -  HOST_WIDE_INT peak;
>> -
>>    if (duplicate)
>>      {
>>        /* We may eliminate the need for out-of-line copy to be output.
>> @@ -279,13 +277,13 @@ cgraph_clone_inlined_nodes (struct cgrap
>>      e->callee->global.inlined_to = e->caller->global.inlined_to;
>>    else
>>      e->callee->global.inlined_to = e->caller;
>> -  e->callee->global.stack_frame_offset
>> -    = e->caller->global.stack_frame_offset
>> -      + inline_summary (e->caller)->estimated_self_stack_size;
>> -  peak = e->callee->global.stack_frame_offset
>> -      + inline_summary (e->callee)->estimated_self_stack_size;
>> -  if (e->callee->global.inlined_to->global.estimated_stack_size < peak)
>> -    e->callee->global.inlined_to->global.estimated_stack_size = peak;
>> +
>> +  /* Pessimistically assume no sharing of stack space.  That is, the
>> +     frame size of a function is estimated as the original frame size
>> +     plus the sum of the frame sizes of all inlined callees.  */
>> +  e->callee->global.inlined_to->global.estimated_stack_size +=
>> +    inline_summary (e->callee)->estimated_self_stack_size;
>> +
>>    cgraph_propagate_frequency (e->callee);
>>
>>    /* Recursively clone all bodies.  */
>> @@ -430,8 +428,7 @@ cgraph_check_inline_limits (struct cgrap
>>
>>    stack_size_limit += stack_size_limit * PARAM_VALUE
>> (PARAM_STACK_FRAME_GROWTH) / 100;
>>
>> -  inlined_stack = (to->global.stack_frame_offset
>> -                  + inline_summary (to)->estimated_self_stack_size
>> +  inlined_stack = (to->global.estimated_stack_size
>>                    + what->global.estimated_stack_size);
>>    if (inlined_stack  > stack_size_limit
>>        && inlined_stack > PARAM_VALUE (PARAM_LARGE_STACK_FRAME))
>> @@ -2064,7 +2061,6 @@ compute_inline_parameters (struct cgraph
>>    self_stack_size = optimize ? estimated_stack_frame_size (node) : 0;
>>    inline_summary (node)->estimated_self_stack_size = self_stack_size;
>>    node->global.estimated_stack_size = self_stack_size;
>> -  node->global.stack_frame_offset = 0;
>>
>>    /* Can this function be inlined at all?  */
>>    node->local.inlinable = tree_inlinable_function_p (node->decl);
>>
>

  reply	other threads:[~2011-06-08  8:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <BANLkTik0OK=0ksWUosRPGW3x23-OAA34ujryD7iimFZH51x58w@mail.gmail.com>
2011-06-08  1:06 ` Xinliang David Li
2011-06-08  9:11   ` Richard Guenther [this message]
2011-06-10  0:08     ` Mark Heffernan
2011-06-10  9:14       ` Richard Guenther

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTi=-Xg9AY2yNw-MgAQ==6RuuGxiyPg@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=davidxl@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=meheff@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).