[PATCH v2] aarch64: Add split-stack initial support

Adhemerval Zanella adhemerval.zanella@linaro.org
Tue Jan 31 20:23:00 GMT 2017



On 25/01/2017 10:10, Jiong Wang wrote:
> On 24/01/17 18:05, Adhemerval Zanella wrote:
>>
>> On 03/01/2017 13:13, Wilco Dijkstra wrote:
>>
>>> +  /* If function uses stacked arguments save the old stack value so morestack
>>> +     can return it.  */
>>> +  reg11 = gen_rtx_REG (Pmode, R11_REGNUM);
>>> +  if (cfun->machine->frame.saved_regs_size
>>> +      || cfun->machine->frame.saved_varargs_size)
>>> +    emit_move_insn (reg11, stack_pointer_rtx);
>>>
>>> This doesn't look right - we could have many arguments even without varargs or
>>> saved regs.  This would need to check varargs as well as ctrl->args.size (I believe
>>> that is the size of the arguments on the stack). It's fine to omit this optimization
>>> in the first version - we already emit 2-3 extra instructions for the check anyway.
>> I will check for a better solution.
> 
> Hi Adhemerval
> 
>   My only concern on this this patch is the initialization of R11 (internal arg
> pointer).  The current implementation looks to me is generating wrong code for a
> testcase simply return the sum of ten int param, I see the function body is
> using R11 while there is no initialization of it in split prologue,  so if the
> execution flow is *not* through __morestack, then R11 is not initialized.
>         As Wilco suggested, I feel using crtl->args.size instead of
> cfun->machine->frame.saved_regs_size might be the correct approach after
> checking assign_parms in function.c.
> 

Hi Jiong,

Indeed the previous version which used 'saved_regs_size' is wrong for stacked
parameters.  A simple 10 arguments function call shows when the reg11 is
evaluated:

cfun->machine->frame.saved_regs_size    = 0
cfun->machine->frame.saved_varargs_size = 0
crtl->args.size                         = 16

So indeed 'ctrl->args.size' seems the correct argument to used in this case
(which will trigger the correct reg11 set for split-stack case).  In this version
I also removed some unused variables I left in previous patch.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-aarch64-Add-split-stack-initial-support.patch
Type: text/x-patch
Size: 30203 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20170131/8b656e58/attachment.bin>


More information about the Gcc-patches mailing list