aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-09-19 16:36:38 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2016-09-19 16:36:38 +0200
commitfc15d9ecb432173f2a17c58352d4b70c1ee049e4 (patch)
tree4965aa4d1c429a1406e32def5da33e5b1008c386 /gcc
parent3c9f5092c6d30a459e06b7db3f0796a1175e2ecc (diff)
downloadgcc-fc15d9ecb432173f2a17c58352d4b70c1ee049e4.zip
gcc-fc15d9ecb432173f2a17c58352d4b70c1ee049e4.tar.gz
gcc-fc15d9ecb432173f2a17c58352d4b70c1ee049e4.tar.bz2
re PR ipa/77587 (C compiler produces incorrect stack alignment with __attribute__((weak)))
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/cgraph.c17
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.dg/pr77587.c14
-rw-r--r--gcc/testsuite/gcc.dg/pr77587a.c23
5 files changed, 62 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2f3f91b..3fb3b0f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 9bc5b6b..0f9df95 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 70d7c56..361ed14 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..1e42f14
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr77587.c
@@ -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
index 0000000..ed98e12
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr77587a.c
@@ -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;
+}