]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR ipa/77587 (C compiler produces incorrect stack alignment with __attri...
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 May 2017 07:26:00 +0000 (09:26 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 May 2017 07:26:00 +0000 (09:26 +0200)
Backported from mainline
2016-09-19  Jakub Jelinek  <jakub@redhat.com>
    Jan Hubicka  <jh@suse.cz>

PR target/77587
* cgraph.c (cgraph_node::rtl_info): Pass &avail to
ultimate_alias_target call, return NULL if avail < AVAIL_AVAILABLE.
Call ultimate_alias_target just once, not up to 4 times.

* gcc.dg/pr77587.c: New test.
* gcc.dg/pr77587a.c: New file.

From-SVN: r248609

gcc/ChangeLog
gcc/cgraph.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr77587.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr77587a.c [new file with mode: 0644]

index 855c5a642c1ab4505f44e15a0355ef4d9ad4a8d6..e0684313adbbdac8d4afd4d6b291865525c2eeed 100644 (file)
@@ -1,6 +1,14 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-09-19  Jakub Jelinek  <jakub@redhat.com>
+                   Jan Hubicka  <jh@suse.cz>
+
+       PR target/77587
+       * cgraph.c (cgraph_node::rtl_info): Pass &avail to
+       ultimate_alias_target call, return NULL if avail < AVAIL_AVAILABLE.
+       Call ultimate_alias_target just once, not up to 4 times.
+
        2016-09-16  Jakub Jelinek  <jakub@redhat.com>
                    Eric Botcazou  <ebotcazou@adacore.com>
 
index 0fcd9364b189d484c44782bce8dc548aeb35077e..fee3ee0e6e2ec798bbd627e7f8b0e1a519ac7370 100644 (file)
@@ -1914,11 +1914,14 @@ cgraph_node::rtl_info (tree decl)
   cgraph_node *node = get (decl);
   if (!node)
     return NULL;
-  node = node->ultimate_alias_target ();
-  if (node->decl != current_function_decl
-      && !TREE_ASM_WRITTEN (node->decl))
+  enum availability avail;
+  node = node->ultimate_alias_target (&avail);
+  if (decl != current_function_decl
+      && (avail < AVAIL_AVAILABLE
+         || (node->decl != current_function_decl
+             && !TREE_ASM_WRITTEN (node->decl))))
     return NULL;
-  return &node->ultimate_alias_target ()->rtl;
+  return &node->rtl;
 }
 
 /* Return a string describing the failure REASON.  */
index f7cdcc87a0b6f65a32a306e22d9f35fd6f0dc3c5..5bec5e04d6aea15789f41eb85603197a312b45f2 100644 (file)
@@ -1,6 +1,13 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-09-19  Jakub Jelinek  <jakub@redhat.com>
+                   Jan Hubicka  <jh@suse.cz>
+
+       PR target/77587
+       * gcc.dg/pr77587.c: New test.
+       * gcc.dg/pr77587a.c: New file.
+
        2016-09-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/77375
diff --git a/gcc/testsuite/gcc.dg/pr77587.c b/gcc/testsuite/gcc.dg/pr77587.c
new file mode 100644 (file)
index 0000000..1e42f14
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR target/77587 */
+/* { dg-do run } */
+/* { dg-require-weak-override "" } */
+/* { dg-additional-sources "pr77587a.c" } */
+
+void
+bar (long x, long y, long z)
+{
+  struct __attribute__((aligned (16))) S { long a, b, c, d; } s;
+  char *p = (char *) &s;
+  __asm ("" : "+r" (p));
+  if (((__UINTPTR_TYPE__) p) & 15)
+    __builtin_abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/pr77587a.c b/gcc/testsuite/gcc.dg/pr77587a.c
new file mode 100644 (file)
index 0000000..ed98e12
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR target/77587 */
+/* { dg-do compile } */
+/* { dg-require-weak-override "" } */
+
+void
+foo (long x, long y, long z)
+{
+}
+
+void bar (long x, long y, long z) __attribute__ ((weak, alias ("foo")));
+
+void
+baz (long x, long y, long z)
+{
+  bar (0, 0, 0);
+}
+
+int
+main ()
+{
+  baz (0, 0, 0);
+  return 0;
+}