re PR ipa/77587 (C compiler produces incorrect stack alignment with __attribute__...
authorJakub Jelinek <jakub@redhat.com>
Mon, 19 Sep 2016 14:36:38 +0000 (16:36 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 19 Sep 2016 14:36:38 +0000 (16:36 +0200)
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.

Co-Authored-By: Jan Hubicka <jh@suse.cz>
From-SVN: r240232

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 2f3f91b4a03fa8b04ec22444393991b9f3998edb..3fb3b0f1e5bd45e7c9c35225bf50ad4d35a19a67 100644 (file)
@@ -1,3 +1,11 @@
+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-19  Richard Biener  <rguenther@suse.de>
 
        * dwarf2out.c (early_dwarf_finished): New global.
index 9bc5b6b7c514a5ac7041587a7e1e3f753bb20b22..0f9df95fd5430d38e94462dfcd90705327983e18 100644 (file)
@@ -1955,14 +1955,17 @@ 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;
-  /* Allocate if it doesnt exist.  */
-  if (node->ultimate_alias_target ()->rtl == NULL)
-    node->ultimate_alias_target ()->rtl = ggc_cleared_alloc<cgraph_rtl_info> ();
-  return node->ultimate_alias_target ()->rtl;
+  /* Allocate if it doesn't exist.  */
+  if (node->rtl == NULL)
+    node->rtl = ggc_cleared_alloc<cgraph_rtl_info> ();
+  return node->rtl;
 }
 
 /* Return a string describing the failure REASON.  */
index 70d7c56535f1b97dac6889b1426c22c822d0a7e6..361ed14ca875139ff9458b682beaf14bb8965adc 100644 (file)
@@ -1,3 +1,10 @@
+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-19  Andre Vehreschild  <vehre@gcc.gnu.org>
 
        * gfortran.dg/coarray/alloc_comp_4.f90: New test.
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;
+}