]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/52129 (wrong code to pass parameters to tail call function)
authorJakub Jelinek <jakub@redhat.com>
Thu, 9 Feb 2012 17:27:25 +0000 (18:27 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 9 Feb 2012 17:27:25 +0000 (18:27 +0100)
Backported from mainline
2012-02-06  Jakub Jelinek  <jakub@redhat.com>

PR target/52129
* calls.c (mem_overlaps_already_clobbered_arg_p): If val is
CONST_INT_P, subtract resp. add crtl->args.pretend_args_size to it.

* gcc.c-torture/execute/pr52129.c: New test.

From-SVN: r184059

gcc/ChangeLog
gcc/calls.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr52129.c [new file with mode: 0644]

index 42ce5e4ca1613bc89c46258d5af1a8abdb8886da..8c2554be0c24330bcb0f194c62d0eca7b64b7c6c 100644 (file)
@@ -1,6 +1,12 @@
 2012-02-09  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2012-02-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/52129
+       * calls.c (mem_overlaps_already_clobbered_arg_p): If val is
+       CONST_INT_P, subtract resp. add crtl->args.pretend_args_size to it.
+
        2012-02-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/48071
index c978e61376819b0163ee18cb5e70abe02b9eae40..4ad6c3fb0fc79e28da24f91617673eeb8c8d6b23 100644 (file)
@@ -1693,6 +1693,11 @@ mem_overlaps_already_clobbered_arg_p (rtx addr, unsigned HOST_WIDE_INT size)
     return true;
   else
     i = INTVAL (val);
+#ifdef STACK_GROWS_DOWNWARD
+  i -= crtl->args.pretend_args_size;
+#else
+  i += crtl->args.pretend_args_size;
+#endif
 
 #ifdef ARGS_GROW_DOWNWARD
   i = -i - size;
index 91e5f2210c308620733d198e45e62dda172c5355..1a7c32951eee381fab50ceb70afac7558ba2b53c 100644 (file)
@@ -1,6 +1,11 @@
 2012-02-09  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2012-02-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/52129
+       * gcc.c-torture/execute/pr52129.c: New test.
+
        2012-01-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/52006
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr52129.c b/gcc/testsuite/gcc.c-torture/execute/pr52129.c
new file mode 100644 (file)
index 0000000..a60bfa8
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR target/52129 */
+
+extern void abort (void);
+struct S { void *p; unsigned int q; };
+struct T { char a[64]; char b[64]; } t;
+
+__attribute__((noinline, noclone)) int
+foo (void *x, struct S s, void *y, void *z)
+{
+  if (x != &t.a[2] || s.p != &t.b[5] || s.q != 27 || y != &t.a[17] || z != &t.b[17])
+    abort ();
+  return 29;
+}
+
+__attribute__((noinline, noclone)) int
+bar (void *x, void *y, void *z, struct S s, int t, struct T *u)
+{
+  return foo (x, s, &u->a[t], &u->b[t]);
+}
+
+int
+main ()
+{
+  struct S s = { &t.b[5], 27 };
+  if (bar (&t.a[2], (void *) 0, (void *) 0, s, 17, &t) != 29)
+    abort ();
+  return 0;
+}