OSDN Git Service

Backported from mainline
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Feb 2013 14:09:38 +0000 (14:09 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Feb 2013 14:09:38 +0000 (14:09 +0000)
2013-01-15  Jakub Jelinek  <jakub@redhat.com>

PR target/55940
* function.c (thread_prologue_and_epilogue_insns): Always
add crtl->drap_reg to set_up_by_prologue.set, even if
stack_realign_drap is false.

* gcc.dg/pr55940.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@195656 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/function.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr55940.c [new file with mode: 0644]

index 6a32dd9..70e2290 100644 (file)
@@ -1,6 +1,13 @@
 2013-02-01  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-01-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/55940
+       * function.c (thread_prologue_and_epilogue_insns): Always
+       add crtl->drap_reg to set_up_by_prologue.set, even if
+       stack_realign_drap is false.
+
        2013-01-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/55921
index f16b5ef..96879c8 100644 (file)
@@ -5961,7 +5961,7 @@ thread_prologue_and_epilogue_insns (void)
       if (pic_offset_table_rtx)
        add_to_hard_reg_set (&set_up_by_prologue.set, Pmode,
                             PIC_OFFSET_TABLE_REGNUM);
-      if (stack_realign_drap && crtl->drap_reg)
+      if (crtl->drap_reg)
        add_to_hard_reg_set (&set_up_by_prologue.set,
                             GET_MODE (crtl->drap_reg),
                             REGNO (crtl->drap_reg));
index 3b7f4dc..c97ee10 100644 (file)
@@ -1,6 +1,11 @@
 2013-02-01  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-01-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/55940
+       * gcc.dg/pr55940.c: New test.
+
        2013-01-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/55921
diff --git a/gcc/testsuite/gcc.dg/pr55940.c b/gcc/testsuite/gcc.dg/pr55940.c
new file mode 100644 (file)
index 0000000..d046d0b
--- /dev/null
@@ -0,0 +1,54 @@
+/* PR target/55940 */
+/* { dg-do run } */
+/* { dg-options "-Os" } */
+/* { dg-additional-options "-mpreferred-stack-boundary=2" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
+
+struct S { int s; unsigned long t; };
+
+__attribute__ ((noinline, noclone)) unsigned long long
+bar (struct S *x, unsigned long y)
+{
+  asm volatile ("" : : "r" (x), "r" (y) : "memory");
+  return x->s + y;
+}
+
+__attribute__ ((noinline, noclone)) unsigned long long
+foo (struct S *x, unsigned long y)
+{
+  unsigned long a;
+  if (__builtin_expect (((__UINTPTR_TYPE__) (x) + 0x1000U < 0x2000U), 0))
+    return ~0ULL;
+  if (__builtin_expect (x->s <= 0 || x->s > 9, 0))
+    return ~0ULL;
+  a = x->t >> 12;
+  if (y == a)
+    return ~0ULL;
+  if (x->s == 3)
+    return x->t + y * 4096;
+  return bar (x, y);
+}
+
+int va, vb, vc, vd;
+
+int
+main ()
+{
+  struct S s;
+  asm volatile ("" : : : "memory");
+  int a = va, b = vb, c = vc, d = vd;
+  asm volatile ("" : : : "memory");
+  int i;
+  for (i = 0; i < 64; i++)
+    if (foo ((struct S *) 0, 0) != ~0ULL)
+      __builtin_abort ();
+  s.s = 3;
+  s.t = 2 << 12;
+  if (foo (&s, 2) != ~0ULL)
+    __builtin_abort ();
+  if (foo (&s, 3) != (2 << 12) + 3 * 4096)
+    __builtin_abort ();
+  asm volatile ("" : : : "memory");
+  va = a; vb = b; vc = c; vd = d;
+  asm volatile ("" : : : "memory");
+  return 0;
+}