public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Sandiford <rsandifo@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/ARM/heads/CVE-2023-4039/gcc-9)] aarch64: Explicitly handle frames with no saved registers
Date: Tue, 12 Sep 2023 15:23:40 +0000 (GMT)	[thread overview]
Message-ID: <20230912152340.618F53857004@sourceware.org> (raw)

https://gcc.gnu.org/g:78ebdb7b12d5e258b9811bab715734454268fd0c

commit 78ebdb7b12d5e258b9811bab715734454268fd0c
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Fri Jun 16 17:00:51 2023 +0100

    aarch64: Explicitly handle frames with no saved registers
    
    If a frame has no saved registers, it can be allocated in one go.
    There is no need to treat the areas below and above the saved
    registers as separate.
    
    And if we allocate the frame in one go, it should be allocated
    as the initial_adjust rather than the final_adjust.  This allows the
    frame size to grow to guard_size - guard_used_by_caller before a stack
    probe is needed.  (A frame with no register saves is necessarily a
    leaf frame.)
    
    This is a no-op as thing stand, since a leaf function will have
    no outgoing arguments, and so all the frame will be above where
    the saved registers normally go.
    
    gcc/
            * config/aarch64/aarch64.c (aarch64_layout_frame): Explicitly
            allocate the frame in one go if there are no saved registers.

Diff:
---
 gcc/config/aarch64/aarch64.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index a35dceab9fc7..e9dad682738f 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -4771,9 +4771,11 @@ aarch64_layout_frame (void)
     max_push_offset = 256;
 
   HOST_WIDE_INT const_size, const_fp_offset;
-  if (cfun->machine->frame.frame_size.is_constant (&const_size)
-      && const_size < max_push_offset
-      && known_eq (crtl->outgoing_args_size, 0))
+  if (cfun->machine->frame.saved_regs_size == 0)
+    cfun->machine->frame.initial_adjust = cfun->machine->frame.frame_size;
+  else if (cfun->machine->frame.frame_size.is_constant (&const_size)
+	   && const_size < max_push_offset
+	   && known_eq (crtl->outgoing_args_size, 0))
     {
       /* Simple, small frame with no outgoing arguments:
 	 stp reg1, reg2, [sp, -frame_size]!

                 reply	other threads:[~2023-09-12 15:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230912152340.618F53857004@sourceware.org \
    --to=rsandifo@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).