From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1624 invoked by alias); 21 Jun 2012 18:27:47 -0000 Received: (qmail 1612 invoked by uid 22791); 21 Jun 2012 18:27:46 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-lb0-f175.google.com (HELO mail-lb0-f175.google.com) (209.85.217.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Jun 2012 18:27:33 +0000 Received: by lbol5 with SMTP id l5so2606482lbo.20 for ; Thu, 21 Jun 2012 11:27:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding:x-system-of-record :x-gm-message-state; bh=pxh5QhIP9V1EOT0f84uquUN6XcD5+Gx45asAZv1cNsE=; b=T04d9wXytTz/PJU1Y5Ys60U2OLROGfL539aS9TpEqUQzAuaa0Sro7sQeH1oMnZdxBA Kw8pofjyy2Jko03mq+94QnPrzK+3cz//imuYuZxndySDPejdmxFxVX/nt60waH6BCpqq FIZYfjpeXJN3oHUjKUxylP31LXATNdt/r0Hg2ZpThtuYY2lJI+LQ8kr9+Bd+dwCnxGio gPIQvBL6o4Td1lWjO0Pbqh/TaTZqNwnNHtpbK4hCj0COP8jRgkFtuTQce+ZPMc9+px/L xOWjSfksfaf/BeALp00ChjAewrF7AIWw/jjOshNwmuwe6Q9i9Cakhej4WR+8u62z8ZMq Sz2w== Received: by 10.112.41.2 with SMTP id b2mr216440lbl.58.1340303252202; Thu, 21 Jun 2012 11:27:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.41.2 with SMTP id b2mr216428lbl.58.1340303251999; Thu, 21 Jun 2012 11:27:31 -0700 (PDT) Received: by 10.152.115.34 with HTTP; Thu, 21 Jun 2012 11:27:31 -0700 (PDT) In-Reply-To: References: <4FE26AFC.3000703@redhat.com> Date: Thu, 21 Jun 2012 18:44:00 -0000 Message-ID: Subject: Re: New option to turn off stack reuse for temporaries From: Xinliang David Li To: Richard Guenther Cc: Jason Merrill , GCC Patches , Michael Matz Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-Gm-Message-State: ALoCoQlb4mu0SjZOLkBZ8eCXOTxaJXRZZR7pNaot1vgZuZsKjjFQgLFMOcTwkqYAo6mwMmF9FWN1ZFh5W6MxOY9v1MbEIARkp+tTj1jE+MbDDikF6JpOUt621GRo8biK85rljLXv8Vg/mBTfx+c6t/TkpXcHbSKUPnmxUFPeV9tNC6D5ocXf/qk7ftmrCjfG4XgpEusK1WZ0 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/msg01429.txt.bz2 On Thu, Jun 21, 2012 at 2:21 AM, Richard Guenther wrote: > On Thu, Jun 21, 2012 at 7:28 AM, Xinliang David Li w= rote: >> 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 automat= ic > variables. =A0The 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 lifet= ime > in other ways, for example if the temporary gets promoted to a register. That should not be an issue then -- if the compiler can figure out the live range via data flow analysis (instead of relying on assertions/markers), the stack reuse or register promotion based on that should always be safe (assuming no bugs in the analysis). > Also with this patch you remove code motion barriers which might cause > other issues. What other issues? It enables more potential code motion, but on the other hand, causes more conservative stack reuse. As far I can tell, the handling of temporaries is added independently after the clobber for scoped variables are introduced. This option can be used to restore the older behavior (in handling temps). thanks, David > > 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 w= hy >>> you might want it on or off. =A0Other than that it looks fine. >>> >>> Jason