This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR target/18916; Function arg passing mem align fixes.


Sorry if this is a duplicate report, but:

Alan Modra <amodra@bigpond.net.au> writes:
> On Sat, Jan 08, 2005 at 01:55:51PM -0800, Richard Henderson wrote:
>> On Sat, Jan 08, 2005 at 10:00:04AM +1030, Alan Modra wrote:
>> > +      stack_parm = assign_stack_local (BLKmode, size_stored, 0);
>> 
>> Don't you know the alignment that you require?
> [...]
> OK, I changed assign_parm_setup_stack to handle mis-aligned stack slots,
> and tweaked some assign_stack_local calls to specify alignment.
> [...]
> +  size = int_size_in_bytes (data->passed_type);
> +  size_stored = CEIL_ROUND (size, UNITS_PER_WORD);
> +  if (stack_parm == 0)
> +    {
> +      stack_parm = assign_stack_local (BLKmode, size_stored,
> +				       TYPE_ALIGN (data->passed_type));

The problem with this is that for REG and PARALLEL parameters,
it's replacing...

>    /* If a BLKmode arrives in registers, copy it to a stack slot.  Handle
>       calls that pass values in multiple non-contiguous locations.  */
>    if (REG_P (entry_parm) || GET_CODE (entry_parm) == PARALLEL)
>      {
> [...]
> -      if (stack_parm == 0)
> -	{
> -	  stack_parm = assign_stack_local (BLKmode, size_stored, 0);
> -	  data->stack_parm = stack_parm;
> -	  PUT_MODE (stack_parm, GET_MODE (entry_parm));
> -	  set_mem_attributes (stack_parm, parm, 1);
> -	}

which gave stack_parm maximum alignment, and allowed the individual
registers to be stored using word-mode moves on strict-alignment targets.
Now it only gets the minimum alignment required for the parameter's
type, which might be less.

An example is:

     struct s { int i, j, k; };
     void f (int i, struct s s) { bar (&s); }

for mips n32.  "s" is allocated a 4-byte aligned stack slot ($fp + 4)
but move_block_from_reg still tries to use word-mode stores.  This is
the cause of the recent IRIX regressions:

    http://gcc.gnu.org/ml/gcc-testresults/2005-01/msg00930.html

Is it OK to go back to using "0" as the alignment, or would you prefer
something like MIN (TYPE_ALIGN (data->passed_type), BITS_PER_WORD) intead?
I suppose another alternative would be to tweak move_block_from_reg
to use unaligned stores, but that would be a code-quality regression.

Richard


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]