Patch: fix regression in PPC sibcalls (redone)

Geoff Keating geoffk@geoffk.org
Sat Jan 4 01:59:00 GMT 2003


Dale Johannesen <dalej@apple.com> writes:

> OK, let's try this again.  I've done this so the behavior is changed
> only in
> the case I know is broken:  REG_PARM_STACK_SPACE>0,
> MAYBE_REG_PARM_STACK_SPACE undefined.
> Daniel Jacobowitz is correct that the patch below precedes ppc
> sibcalls in the FSF sources;
> still, it doesn't do the right thing for ppc (sparc, etc.) so a
> reference is useful:
> 
> Wed Apr 24 21:58:09 2002  J"orn Rennecke <joern.rennecke@superh.com>
>          * calls.c (expand_call): Take current_function_pretend_args_size
>          into account when setting argblock for sibcalls.
> 
> It is not right to do the adjustment in that patch when the caller has
> already allocated
> the stack space for partially-in-regs params.  Bootstrapped and tested
> on darwin.

I'm looking at this patch and Jorn's patch trying to work out what is
correct.  pretend_args_size is defined as this:

  /* # bytes the prologue should push and pretend that the caller pushed them.
     The prologue must do this, but only if parms can be passed in
     registers.  */

So it seems to me that Jorn's patch ought to be correct.  If the
prologue does this, then the epilogue will need to undo it, and so any
outgoing arguments should start after the extra space.

In the original mail, Dale said:

> It is not right to do the adjustment in that patch when the caller
> has already allocated the stack space for partially-in-regs params

but in that case (when OUTGOING_REG_PARM_STACK_SPACE is set and
REG_PARM_STACK_SPACE is nonzero), pretend_args_size should be zero,
since if the caller has already allocated the space then the prologue
shouldn't.  So I think the real problem is that in assign_parms
in function.c, current_function_pretend_args_size is set
unconditionally, but it shouldn't be set in this case.

The problem wouldn't have been noticed on powerpc before, because the
powerpc prologue/epilogue generation never actually looks at
current_function_pretend_args_size.  The only place it's used is when
it is set in setup_incoming_varargs, and I think that is also
incorrect ---the comment above it is "??? Does ABI_V4 need this at
all?", and as far as I can tell it has no effect other than on sibcall
processing.

> 2003-01-03  Dale Johannesen  <dalej@apple.com>
> 
>          * calls.c (expand_call):  Fix sibcalls on
> REG_PARM_STACK_SPACE machines.

-- 
- Geoffrey Keating <geoffk@geoffk.org>



More information about the Gcc-patches mailing list