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: Jason Merrill <jason@redhat.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
		Michael Matz <matz@suse.de>
Subject: Re: New option to turn off stack reuse for temporaries
Date: Thu, 21 Jun 2012 09:32:00 -0000	[thread overview]
Message-ID: <CAFiYyc2_genu4SOJ963YqforcuopxXDWYXUeC6=66V-2pYEPXw@mail.gmail.com> (raw)
In-Reply-To: <CAAkRFZL_WkRtxRD4_U=_KzfPGtnmf=QxJSN_E=KfROKwTALjHQ@mail.gmail.com>

On Thu, Jun 21, 2012 at 7:28 AM, Xinliang David Li <davidxl@google.com> wrote:
> I modified the documentation and it now looks like this:
>
> @item -ftemp-stack-reuse
> @opindex ftemp_stack_reuse
> This option enables stack space reuse for temporaries. The default is on.
> The lifetime of a compiler generated temporary is well defined by the C++
> standard. When a lifetime of a temporary ends, and if the temporary lives
> in memory, an optimizing compiler has the freedom to reuse its stack
> space with other temporaries or scoped local variables whose live range
> does not overlap with it. However some of the legacy code relies on
> the behavior of older compilers in which temporaries' stack space is
> not reused, the aggressive stack reuse can lead to runtime errors. This
> option is used to control the temporary stack reuse optimization.
>
> Does it look ok?

The flag is not restricted to the C++ compiler and applies to all automatic
variables.  The description is very much C++ specific though - I think
it should mention the concept of scopes.

Also even with this flag there is no guarantee we cannot figure out lifetime
in other ways, for example if the temporary gets promoted to a register.
Also with this patch you remove code motion barriers which might cause
other issues.

A more "proper" place to fix this is when we actually do the stack reuse,
in cfgexpand.

So no, I don't think the patch is ok as-is.

Thanks,
Richard.

> thanks,
>
> David
>
> On Wed, Jun 20, 2012 at 5:29 PM, Jason Merrill <jason@redhat.com> wrote:
>> The documentation needs to explain more what the option controls, and why
>> you might want it on or off.  Other than that it looks fine.
>>
>> Jason

  parent reply	other threads:[~2012-06-21  9:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-20 23:44 Xinliang David Li
2012-06-21  5:28 ` Jason Merrill
2012-06-21  6:06   ` Xinliang David Li
2012-06-21  6:27     ` Jason Merrill
2012-06-21  9:32     ` Richard Guenther [this message]
2012-06-21 16:41       ` Michael Matz
2012-06-22  8:46         ` Richard Guenther
2012-06-21 18:19       ` Jason Merrill
2012-06-21 18:44       ` Xinliang David Li
2012-06-22  8:50         ` Richard Guenther
2012-06-22  9:39           ` Jason Merrill
2012-06-22  9:51             ` Richard Guenther
2012-06-22 16:09               ` Xinliang David Li
2012-06-25 16:29                 ` Xinliang David Li
2012-06-26  8:42                   ` Richard Guenther
2012-06-26 15:29                     ` Jason Merrill
2012-06-26 17:12                       ` Michael Matz
2012-06-26 17:19                         ` Jakub Jelinek
2012-06-26 20:12                         ` Mike Stump
2012-06-27  3:03                           ` Eric Botcazou
2012-06-29  8:18                     ` Xinliang David Li
2012-07-02 23:30                       ` Xinliang David Li
2012-07-04 15:01                         ` Xinliang David Li
2012-07-09 16:31                           ` Xinliang David Li
2012-07-09 22:53                         ` Jason Merrill
2012-12-02 12:32 ` Olivier Ballereau
2012-12-03  1:03   ` Xinliang David Li
2012-06-22 21:09 Jason Merrill

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='CAFiYyc2_genu4SOJ963YqforcuopxXDWYXUeC6=66V-2pYEPXw@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=davidxl@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=matz@suse.de \
    /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).