From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26066 invoked by alias); 29 Jun 2012 05:43:30 -0000 Received: (qmail 25869 invoked by uid 22791); 29 Jun 2012 05:43:27 -0000 X-SWARE-Spam-Status: No, hits=-5.6 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,TW_CF,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; Fri, 29 Jun 2012 05:43:05 +0000 Received: by lbol5 with SMTP id l5so4498130lbo.20 for ; Thu, 28 Jun 2012 22:43:04 -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=UUENcVf6520JXn4twPKHwGtFGyobVM6vUVZ7DRtTdW8=; b=TrKnbRX5M7yBlkCV2ixOet98sGckXKhn9Q5q7wpGWhNWNu07ZULM3En2liipMqiMaV BCsXGa94LwIjOc0Zxmm5i69EYRte7h5WaJjOBT4/VIY7Xrv0mmb6eytV71RW6KPTB+3l SU0QNSZzqJ86P1le3w6XkurI0qqaj+7gAOqGGtol0/yALmybm46T8bjHDLy3W82TqWmw Lh7AHDJw381NnOSpQa3Eed6XEIPDwqCxmGTBG3EUqd2S4D4MfABdxJIIHeMV3n6gULQu EXpW+bCTfm/znnlO0mpaxAHxb2tz0fuPkOWFIZS2Na3SvPpnc5oKI83ls+Huh/Vowr34 o9Sw== Received: by 10.152.148.195 with SMTP id tu3mr351518lab.16.1340948584067; Thu, 28 Jun 2012 22:43:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.152.148.195 with SMTP id tu3mr351502lab.16.1340948583849; Thu, 28 Jun 2012 22:43:03 -0700 (PDT) Received: by 10.152.115.34 with HTTP; Thu, 28 Jun 2012 22:43:03 -0700 (PDT) In-Reply-To: References: <4FE26AFC.3000703@redhat.com> <4FE43AFD.6050601@redhat.com> Date: Fri, 29 Jun 2012 08:18: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: ALoCoQliNCi6No0iOTfMmIlhWyvJB0i9LeAq8rJC3U8uSxtvvgUc+9cOVEA3GsDJDduU5mpkyTqIqLZS9PZOEcQevlzsbU2sruMbfuXIvxaa26nhQ+SerSQX5kIxPTaFMFS9wUxeBj/u51RQvD3G//kqrBSdlSTUsFogiffLl2zo0emnoNfeWzbb0NW0diV4W//g9mOTV7ET 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/msg01907.txt.bz2 (re-post in plain text) Moving this to cfgexpand time is simple and it can also be extended to handle scoped variables. However Jakub raised a good point about this being too late as stack space overlay is not the only way to cause trouble when the lifetime of a stack object is extended beyond the clobber stmt. thanks, David On Tue, Jun 26, 2012 at 1:28 AM, Richard Guenther wrote: > On Mon, Jun 25, 2012 at 6:25 PM, Xinliang David Li w= rote: >> Are there any more concerns about this patch? If not, I'd like to check = it in. > > No - the fact that the flag is C++ specific but in common.opt is odd enou= gh > and -ftemp-reuse-stack sounds very very generic - which in fact it is not, > it's a no-op in C. =A0Is there a more formal phrase for the temporary kin= d that > is affected? =A0For me "temp" is synonymous to "auto" so I'd have expected > the switch to turn off stack slot sharing for > > =A0{ > =A0 int a[5]; > =A0} > =A0{ > =A0 int a[5]; > =A0} > > but that is not what it does. =A0So - a little kludgy but probably more t= o what > I'd like it to be would be to move the option to c-family/c.opt enabled o= nly > for C++ and Obj-C++ and export it to the middle-end via a new langhook > (the gimplifier code should be in Frontend code that lowers to GENERIC > really and the WITH_CLEANUP_EXPR code should be C++ frontend specific ...= ). > > Thanks, > Richard. > >> thanks, >> >> David >> >> On Fri, Jun 22, 2012 at 8:51 AM, Xinliang David Li = wrote: >>> On Fri, Jun 22, 2012 at 2:39 AM, Richard Guenther >>> wrote: >>>> On Fri, Jun 22, 2012 at 11:29 AM, Jason Merrill wro= te: >>>>> On 06/22/2012 01:30 AM, Richard Guenther wrote: >>>>>>> >>>>>>> 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). >>>>>> >>>>>> >>>>>> Well, it does not really restore the old behavior (if you mean before >>>>>> adding >>>>>> CLOBBERS, not before the single patch that might have used those for >>>>>> gimplifying WITH_CLEANUP_EXPR). =A0You say it disables stack-slot sh= aring >>>>>> for those decls but it also does other things via side-effects of no >>>>>> longer >>>>>> emitting the CLOBBER. =A0I say it's better to disable the stack-slot >>>>>> sharing. >>>>> >>>>> >>>>> The patch exactly restores the behavior of temporaries from before my= change >>>>> to add CLOBBERs for temporaries. =A0The primary effect of that change= was to >>>>> provide stack-slot sharing, but if there are other effects they are p= robably >>>>> desirable as well, since the broken code depended on the old behavior. >>>> >>>> So you see it as workaround option, like -fno-strict-aliasing, rather = than >>>> debugging aid? >>> >>> It can be used for both purposes -- if the violations are as pervasive >>> as strict-aliasing cases (which looks like so). >>> >>> thanks, >>> >>> David >>> >>>> >>>> Richard. >>>> >>>>> Jason