From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7713 invoked by alias); 21 Jun 2012 09:22:11 -0000 Received: (qmail 7613 invoked by uid 22791); 21 Jun 2012 09:22:09 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-ob0-f175.google.com (HELO mail-ob0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Jun 2012 09:21:56 +0000 Received: by obcva7 with SMTP id va7so717879obc.20 for ; Thu, 21 Jun 2012 02:21:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.18.136 with SMTP id w8mr27535859obd.38.1340270515587; Thu, 21 Jun 2012 02:21:55 -0700 (PDT) Received: by 10.76.82.4 with HTTP; Thu, 21 Jun 2012 02:21:55 -0700 (PDT) In-Reply-To: References: <4FE26AFC.3000703@redhat.com> Date: Thu, 21 Jun 2012 09:32:00 -0000 Message-ID: Subject: Re: New option to turn off stack reuse for temporaries From: Richard Guenther To: Xinliang David Li Cc: Jason Merrill , GCC Patches , Michael Matz Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-06/txt/msg01403.txt.bz2 On Thu, Jun 21, 2012 at 7:28 AM, Xinliang David Li wro= te: > 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 wrote: >> The documentation needs to explain more what the option controls, and why >> you might want it on or off. =A0Other than that it looks fine. >> >> Jason