From: Jakub Jelinek Date: Tue, 30 May 2017 07:26:00 +0000 (+0200) Subject: backport: re PR ipa/77587 (C compiler produces incorrect stack alignment with __attri... X-Git-Tag: releases/gcc-5.5.0~301 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a3638198caab896fc23e012843082121106f7ea;p=thirdparty%2Fgcc.git backport: re PR ipa/77587 (C compiler produces incorrect stack alignment with __attribute__((weak))) Backported from mainline 2016-09-19 Jakub Jelinek Jan Hubicka 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 855c5a642c1a..e0684313adbb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,14 @@ 2017-05-30 Jakub Jelinek Backported from mainline + 2016-09-19 Jakub Jelinek + Jan Hubicka + + 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 Eric Botcazou diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 0fcd9364b189..fee3ee0e6e2e 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f7cdcc87a0b6..5bec5e04d6ae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,13 @@ 2017-05-30 Jakub Jelinek Backported from mainline + 2016-09-19 Jakub Jelinek + Jan Hubicka + + PR target/77587 + * gcc.dg/pr77587.c: New test. + * gcc.dg/pr77587a.c: New file. + 2016-09-16 Jakub Jelinek PR c++/77375 diff --git a/gcc/testsuite/gcc.dg/pr77587.c b/gcc/testsuite/gcc.dg/pr77587.c new file mode 100644 index 000000000000..1e42f142f7a0 --- /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 000000000000..ed98e12b87e7 --- /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; +}