public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [AArch64] Question about the condition of calls_alloca in aarch64_layout_frame
@ 2022-02-07  9:15 Dan Li
  0 siblings, 0 replies; only message in thread
From: Dan Li @ 2022-02-07  9:15 UTC (permalink / raw)
  To: gcc-patches

There is the following code in aarch64_layout_frame:

else if (crtl->outgoing_args_size.is_constant (&const_outgoing_args_size)
          && frame.saved_regs_size.is_constant (&const_saved_regs_size)
          && const_outgoing_args_size + const_saved_regs_size < 512
          && (!saves_below_hard_fp_p || const_outgoing_args_size == 0)
								    // 1)
          && !(cfun->calls_alloca				
               && frame.hard_fp_offset.is_constant (&const_fp_offset)
               && const_fp_offset < max_push_offset))
   {
     /* Frame with small outgoing arguments:

        sub sp, sp, frame_size
        stp reg1, reg2, [sp, outgoing_args_size]
        stp reg3, reg4, [sp, outgoing_args_size + 16]  */
     frame.initial_adjust = frame.frame_size;
     frame.callee_offset = const_outgoing_args_size;
   }
......
else if (frame.hard_fp_offset.is_constant (&const_fp_offset)
          && const_fp_offset < max_push_offset)
   {
								    // 2)
     /* Frame with large outgoing arguments or SVE saves, but with
        a small local area:

        stp reg1, reg2, [sp, -hard_fp_offset]!
        stp reg3, reg4, [sp, 16]
        [sub sp, sp, below_hard_fp_saved_regs_size]
        [save SVE registers relative to SP]
        sub sp, sp, outgoing_args_size  */


As described in 2), "Frame with large outgoing arguments or SVE saves,
but with a small local area".

But due to the condition at 1), the following code (small outgoing with
a small local area) also uses the insns in 2), which is slightly different
from the description:

//aarch64-linux-gnu-gcc   main.c -O0 -S main.s -g -w -fomit-frame-pointer

#include <stdio.h>
#include <alloca.h>
#define REP9(X) X,X,X,X,X,X,X,X,X

int alloc_size;

int main(void)
{
         outgoing (REP9(1));
         char * y = alloca(alloc_size);
         return 0;
}


Could the condition in 1) be removed, or am I missing something?

Thanks,
Dan.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-02-07  9:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07  9:15 [AArch64] Question about the condition of calls_alloca in aarch64_layout_frame Dan Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).