]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Simplify probe of final frame allocation
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 12 Sep 2023 15:05:11 +0000 (16:05 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 12 Sep 2023 15:05:11 +0000 (16:05 +0100)
Previous patches ensured that the final frame allocation only needs
a probe when the size is strictly greater than 1KiB.  It's therefore
safe to use the normal 1024 probe offset in all cases.

The main motivation for doing this is to simplify the code and
remove the number of special cases.

gcc/
* config/aarch64/aarch64.cc (aarch64_allocate_and_probe_stack_space):
Always probe the residual allocation at offset 1024, asserting
that that is in range.

gcc/testsuite/
* gcc.target/aarch64/stack-check-prologue-17.c: Expect the probe
to be at offset 1024 rather than offset 0.
* gcc.target/aarch64/stack-check-prologue-18.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-19.c: Likewise.

gcc/config/aarch64/aarch64.cc
gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
gcc/testsuite/gcc.target/aarch64/stack-check-prologue-19.c

index 383b32f2078c5bf997c63e6fecae540b351df73f..bcb879ba94bda2d82e36aca2fc4f26ec79c1a0bc 100644 (file)
@@ -9887,16 +9887,12 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
      are still safe.  */
   if (residual)
     {
-      HOST_WIDE_INT residual_probe_offset = guard_used_by_caller;
+      gcc_assert (guard_used_by_caller + byte_sp_alignment <= size);
+
       /* If we're doing final adjustments, and we've done any full page
         allocations then any residual needs to be probed.  */
       if (final_adjustment_p && rounded_size != 0)
        min_probe_threshold = 0;
-      /* If doing a small final adjustment, we always probe at offset 0.
-        This is done to avoid issues when the final adjustment is smaller
-        than the probing offset.  */
-      else if (final_adjustment_p && rounded_size == 0)
-       residual_probe_offset = 0;
 
       aarch64_sub_sp (temp1, temp2, residual, frame_related_p);
       if (residual >= min_probe_threshold)
@@ -9907,8 +9903,8 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
                     HOST_WIDE_INT_PRINT_DEC " bytes, probing will be required."
                     "\n", residual);
 
-           emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx,
-                                            residual_probe_offset));
+         emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx,
+                                          guard_used_by_caller));
          emit_insn (gen_blockage ());
        }
     }
index 0d8a25d73a24d1532c05bcb90b8ed617951b0b08..f0ec1389771d94775e1549341cbefd9cb9170ebb 100644 (file)
@@ -33,7 +33,7 @@ int test1(int z) {
 **     ...
 **     str     x30, \[sp\]
 **     sub     sp, sp, #1040
-**     str     xzr, \[sp\]
+**     str     xzr, \[sp, #?1024\]
 **     cbnz    w0, .*
 **     bl      g
 **     ...
index 82447d20fff579b985e22a1c3041ce899c6ebb57..6383bec5ebcd5f5982d673b33b80de503d19c278 100644 (file)
@@ -9,7 +9,7 @@ void g();
 **     ...
 **     str     x30, \[sp\]
 **     sub     sp, sp, #4064
-**     str     xzr, \[sp\]
+**     str     xzr, \[sp, #?1024\]
 **     cbnz    w0, .*
 **     bl      g
 **     ...
@@ -50,7 +50,7 @@ int test1(int z) {
 **     ...
 **     str     x30, \[sp\]
 **     sub     sp, sp, #1040
-**     str     xzr, \[sp\]
+**     str     xzr, \[sp, #?1024\]
 **     cbnz    w0, .*
 **     bl      g
 **     ...
index 73ac3e4e4eb02befea96bf33bc59787451c8dda4..562039b5e9b8b24fe2141ed6562598e543db33f0 100644 (file)
@@ -9,7 +9,7 @@ void g();
 **     ...
 **     str     x30, \[sp\]
 **     sub     sp, sp, #4064
-**     str     xzr, \[sp\]
+**     str     xzr, \[sp, #?1024\]
 **     cbnz    w0, .*
 **     bl      g
 **     ...
@@ -50,7 +50,7 @@ int test1(int z) {
 **     ...
 **     str     x30, \[sp\]
 **     sub     sp, sp, #1040
-**     str     xzr, \[sp\]
+**     str     xzr, \[sp, #?1024\]
 **     cbnz    w0, .*
 **     bl      g
 **     ...