https://gcc.gnu.org/g:21746f3c5e8da59b52d49226e6ba3e37c49257a7

commit r17-6356-g21746f3c5e8da59b52d49226e6ba3e37c49257a7
Author: Dominic P <[email protected]>
Date:   Mon Sep 7 19:41:21 2026 +0100

    testsuite: execution test for an over-aligned scalar parameter [PR97473]
    
    8aaa5f6e620 ("function: honour over-alignment in assign_stack_local")
    also fixes PR97473: an over-aligned scalar parameter whose address is
    taken was spilled by assign_parm_setup_stack through
    assign_stack_local, so its slot got whatever alignment the frame could
    promise.  Add the execution test.
    
    Aborted on arm-none-eabi (armv6, qemu) before that commit.
    
    Assisted-by: Claude Opus 5 (Anthropic)
    
            PR middle-end/97473
    
    gcc/testsuite/ChangeLog:
    
            PR middle-end/97473
            * gcc.dg/pr97473.c: New test.
    
    Signed-off-by: Dominic P <[email protected]>

Diff:
---
 gcc/testsuite/gcc.dg/pr97473.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/pr97473.c b/gcc/testsuite/gcc.dg/pr97473.c
new file mode 100644
index 000000000000..bc7fd2e73307
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr97473.c
@@ -0,0 +1,33 @@
+/* An over-aligned scalar parameter whose address is taken.  */
+
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#define ALIGNMENT 64
+
+typedef int V __attribute__((aligned (ALIGNMENT)));
+
+void check (V *) __attribute__((noipa));
+void two (V, V) __attribute__((noipa));
+
+void
+check (V *p)
+{
+  if ((__UINTPTR_TYPE__) p % ALIGNMENT != 0)
+    __builtin_abort ();
+}
+
+/* Two parameters, in case one is sufficiently aligned by chance.  */
+void
+two (V x, V y)
+{
+  check (&x);
+  check (&y);
+}
+
+int
+main (void)
+{
+  two (-43, 29);
+  return 0;
+}

Reply via email to