From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31964 invoked by alias); 14 Apr 2011 14:30:27 -0000 Received: (qmail 31955 invoked by uid 22791); 14 Apr 2011 14:30:26 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Apr 2011 14:30:20 +0000 Received: by wwf26 with SMTP id 26so1975516wwf.8 for ; Thu, 14 Apr 2011 07:30:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.30.164 with SMTP id u36mr867368wbc.118.1302791418971; Thu, 14 Apr 2011 07:30:18 -0700 (PDT) Received: by 10.227.0.140 with HTTP; Thu, 14 Apr 2011 07:30:18 -0700 (PDT) In-Reply-To: References: <20110414133453.GA18805@intel.com> Date: Thu, 14 Apr 2011 14:30:00 -0000 Message-ID: Subject: Re: PATCH: PR middle-end/48608: Alignment adjust of local variables is lost From: Richard Guenther To: "H.J. Lu" Cc: GCC Patches 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: 2011-04/txt/msg01077.txt.bz2 On Thu, Apr 14, 2011 at 4:27 PM, H.J. Lu wrote: > On Thu, Apr 14, 2011 at 7:09 AM, Richard Guenther > wrote: >> On Thu, Apr 14, 2011 at 4:01 PM, H.J. Lu wrote: >>> On Thu, Apr 14, 2011 at 6:57 AM, Richard Guenther >>> wrote: >>>> On Thu, Apr 14, 2011 at 3:34 PM, H.J. Lu wrote: >>>>> We have >>>>> >>>>> static unsigned int >>>>> get_decl_align_unit (tree decl) >>>>> { >>>>> =A0unsigned int align =3D LOCAL_DECL_ALIGNMENT (decl); >>>>> =A0return align / BITS_PER_UNIT; >>>>> } >>>>> >>>>> LOCAL_DECL_ALIGNMENT may increase alignment for local variable. =A0Bu= t it is >>>>> never saved. =A0DECL_ALIGN (decl) returns the old alignment. =A0This = patch >>>>> updates DECL_ALIGN if needed. =A0OK for trunk if there are no regress= ions? >>>> >>>> A get_* function does not seem like a good place to do such things. >>> >>> Any suggestion to how to do it properly? I can rename >>> get_decl_align_unit to align_local_variable. >> >> That works for me. >> >>>> Why does it matter that DECL_ALIGN is updated? >>>> >>> >>> My port needs accurate alignment information on local variables. >> >> I see. > > Here is the updated patch. =A0OK for trunk if there are no regressions? > > Thanks. > > -- > H.J. > --- > 2011-04-14 =A0H.J. Lu =A0 > > =A0 =A0 =A0 =A0PR middle-end/48608 > =A0 =A0 =A0 =A0* cfgexpand.c (get_decl_align_unit): Renamed to ... > =A0 =A0 =A0 =A0(align_local_variable): This. =A0Update DECL_ALIGN if need= ed. > =A0 =A0 =A0 =A0(add_stack_var): Updated. > =A0 =A0 =A0 =A0(expand_one_stack_var): Likewise. > > diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c > index cc1382f..d38d2f9 100644 > --- a/gcc/cfgexpand.c > +++ b/gcc/cfgexpand.c > @@ -205,13 +205,15 @@ static bool has_protected_decls; > =A0 =A0smaller than our cutoff threshold. =A0Used for -Wstack-protector. = =A0*/ > =A0static bool has_short_buffer; > > -/* Discover the byte alignment to use for DECL. =A0Ignore alignment > +/* Compute the byte alignment to use for DECL. =A0Ignore alignment > =A0 =A0we can't do with expected alignment of the stack boundary. =A0*/ > > =A0static unsigned int > -get_decl_align_unit (tree decl) > +align_local_variable (tree decl) > =A0{ > =A0 unsigned int align =3D LOCAL_DECL_ALIGNMENT (decl); > + =A0if (align > DECL_ALIGN (decl)) > + =A0 =A0DECL_ALIGN (decl) =3D align; Shouldn't this unconditionally set DECL_ALIGN in case LOCAL_DECL_ALINGMENT returns something smaller? Ok with that change. Thanks, Richard. > =A0 return align / BITS_PER_UNIT; > =A0} > > @@ -273,7 +275,7 @@ add_stack_var (tree decl) > =A0 =A0 =A0variables that are simultaneously live. =A0*/ > =A0 if (v->size =3D=3D 0) > =A0 =A0 v->size =3D 1; > - =A0v->alignb =3D get_decl_align_unit (SSAVAR (decl)); > + =A0v->alignb =3D align_local_variable (SSAVAR (decl)); > > =A0 /* All variables are initially in their own partition. =A0*/ > =A0 v->representative =3D stack_vars_num; > @@ -905,7 +907,7 @@ expand_one_stack_var (tree var) > =A0 unsigned byte_align; > > =A0 size =3D tree_low_cst (DECL_SIZE_UNIT (SSAVAR (var)), 1); > - =A0byte_align =3D get_decl_align_unit (SSAVAR (var)); > + =A0byte_align =3D align_local_variable (SSAVAR (var)); > > =A0 /* We handle highly aligned variables in expand_stack_vars. =A0*/ > =A0 gcc_assert (byte_align * BITS_PER_UNIT <=3D MAX_SUPPORTED_STACK_ALIGN= MENT); >