]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
pdp11: Fix epilogue generation [PR107841]
authorMikael Pettersson <mikpelinux@gmail.com>
Thu, 13 Jul 2023 20:06:39 +0000 (16:06 -0400)
committerPaul Koning <paulkoning@comcast.net>
Thu, 13 Jul 2023 20:09:15 +0000 (16:09 -0400)
gcc/

PR target/107841
* config/pdp11/pdp11.cc (pdp11_expand_epilogue): Also
deallocate alloca-only frame.

gcc/testsuite/

PR target/107841
* gcc.target/pdp11/pr107841.c: New test.

gcc/config/pdp11/pdp11.cc
gcc/testsuite/gcc.target/pdp11/pr107841.c [new file with mode: 0644]

index f6dd841f1847d158c3e331c61cce33cdb0524eae..311a1d225e0535c66cd4ec3a4d6552f4faee2cdf 100644 (file)
@@ -393,7 +393,7 @@ pdp11_expand_epilogue (void)
   rtx x, reg, via_ac = NULL;
 
   /* Deallocate the local variables.  */
-  if (fsize)
+  if (fsize || cfun->calls_alloca)
     {
       if (frame_pointer_needed)
        {
diff --git a/gcc/testsuite/gcc.target/pdp11/pr107841.c b/gcc/testsuite/gcc.target/pdp11/pr107841.c
new file mode 100644 (file)
index 0000000..a363c46
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+/* Verify that the stack frame is deallocated using the frame pointer.  */
+
+void qq (int a)
+{
+    char *s = __builtin_alloca (128);
+    __builtin_sprintf (s, "qq %d", 3);
+}
+
+/* { dg-final { scan-assembler "mov\tr5,sp" } } */