PATCH: PR middle-end/48608: Alignment adjust of local variables is lost

Richard Guenther richard.guenther@gmail.com
Thu Apr 14 13:57:00 GMT 2011


On Thu, Apr 14, 2011 at 3:34 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> We have
>
> static unsigned int
> get_decl_align_unit (tree decl)
> {
>  unsigned int align = LOCAL_DECL_ALIGNMENT (decl);
>  return align / BITS_PER_UNIT;
> }
>
> LOCAL_DECL_ALIGNMENT may increase alignment for local variable.  But it is
> never saved.  DECL_ALIGN (decl) returns the old alignment.  This patch
> updates DECL_ALIGN if needed.  OK for trunk if there are no regressions?

A get_* function does not seem like a good place to do such things.
Why does it matter that DECL_ALIGN is updated?

> Thanks.
>
> H.J.
> ---
> 2011-04-14  H.J. Lu  <hongjiu.lu@intel.com>
>
>        PR middle-end/48608
>        * cfgexpand.c (get_decl_align_unit): Update DECL_ALIGN if needed.
>
> diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
> index cc1382f..e79d50c 100644
> --- a/gcc/cfgexpand.c
> +++ b/gcc/cfgexpand.c
> @@ -212,6 +212,8 @@ static unsigned int
>  get_decl_align_unit (tree decl)
>  {
>   unsigned int align = LOCAL_DECL_ALIGNMENT (decl);
> +  if (align > DECL_ALIGN (decl))
> +    DECL_ALIGN (decl) = align;
>   return align / BITS_PER_UNIT;
>  }
>
>



More information about the Gcc-patches mailing list