diff options
author | marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-09-15 08:12:30 +0000 |
---|---|---|
committer | marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-09-15 08:12:30 +0000 |
commit | 3b7050a3864b2a9e6303e0d24f0d2b60eb2896f7 (patch) | |
tree | 85d7ba2a46d295532252d5fc98f4b7ddb549fe47 | |
parent | 18412c43bb805182f8d3f07d5f47bf53f4cacc70 (diff) | |
download | gcc-3b7050a3864b2a9e6303e0d24f0d2b60eb2896f7.tar.gz |
Backport r249735
2017-09-15 Martin Liska <mliska@suse.cz>
Backport from mainline
2017-06-28 Martin Liska <mliska@suse.cz>
PR ipa/81128
* ipa-visibility.c (non_local_p): Handle visibility.
2017-09-15 Martin Liska <mliska@suse.cz>
Backport from mainline
2017-06-28 Martin Liska <mliska@suse.cz>
PR ipa/81128
* c-attribs.c (handle_alias_ifunc_attribute): Append ifunc alias
to a function declaration.
2017-09-15 Martin Liska <mliska@suse.cz>
Backport from mainline
2017-06-28 Martin Liska <mliska@suse.cz>
PR ipa/81128
* gcc.target/i386/pr81128.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@252782 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/c-family/c-attribs.c | 11 | ||||
-rw-r--r-- | gcc/ipa-visibility.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr81128.c | 65 |
6 files changed, 100 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c7b62274448..48580a4404c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-06-28 Martin Liska <mliska@suse.cz> + + PR ipa/81128 + * ipa-visibility.c (non_local_p): Handle visibility. + 2017-09-12 Bill Schmidt <wschmidt@linux.vnet.ibm.com> Backport from mainline diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 14482a53d3f..ef191fee5b2 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,12 @@ +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-06-28 Martin Liska <mliska@suse.cz> + + PR ipa/81128 + * c-attribs.c (handle_alias_ifunc_attribute): Append ifunc alias + to a function declaration. + 2017-09-10 Jonathan Wakely <jwakely@redhat.com> PR c++/81852 diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index f2a88e147ba..90b17bc00d2 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -1764,9 +1764,14 @@ handle_alias_ifunc_attribute (bool is_alias, tree *node, tree name, tree args, TREE_STATIC (decl) = 1; if (!is_alias) - /* ifuncs are also aliases, so set that attribute too. */ - DECL_ATTRIBUTES (decl) - = tree_cons (get_identifier ("alias"), args, DECL_ATTRIBUTES (decl)); + { + /* ifuncs are also aliases, so set that attribute too. */ + DECL_ATTRIBUTES (decl) + = tree_cons (get_identifier ("alias"), args, + DECL_ATTRIBUTES (decl)); + DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("ifunc"), + NULL, DECL_ATTRIBUTES (decl)); + } } else { diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c index d5a3ae56c46..da4a22e7329 100644 --- a/gcc/ipa-visibility.c +++ b/gcc/ipa-visibility.c @@ -97,7 +97,8 @@ non_local_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) && !DECL_EXTERNAL (node->decl) && !node->externally_visible && !node->used_from_other_partition - && !node->in_other_partition); + && !node->in_other_partition + && node->get_availability () >= AVAIL_AVAILABLE); } /* Return true when function can be marked local. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b91509e26c1..727ca226e94 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-06-28 Martin Liska <mliska@suse.cz> + + PR ipa/81128 + * gcc.target/i386/pr81128.c: New test. + 2017-09-12 Bill Schmidt <wschmidt@linux.vnet.ibm.com> Backport from mainline diff --git a/gcc/testsuite/gcc.target/i386/pr81128.c b/gcc/testsuite/gcc.target/i386/pr81128.c new file mode 100644 index 00000000000..90a567ad690 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr81128.c @@ -0,0 +1,65 @@ +/* PR ipa/81128 */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +/* { dg-require-ifunc "" } */ + + +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +int resolver_fn = 0; +int resolved_fn = 0; + +static inline void +do_it_right_at_runtime_A () +{ + resolved_fn++; +} + +static inline void +do_it_right_at_runtime_B () +{ + resolved_fn++; +} + +static inline void do_it_right_at_runtime (void); + +void do_it_right_at_runtime (void) + __attribute__ ((ifunc ("resolve_do_it_right_at_runtime"))); + +static void (*resolve_do_it_right_at_runtime (void)) (void) +{ + srand (time (NULL)); + int r = rand (); + resolver_fn++; + + /* Use intermediate variable to get a warning for non-matching + * prototype. */ + typeof(do_it_right_at_runtime) *func; + if (r & 1) + func = do_it_right_at_runtime_A; + else + func = do_it_right_at_runtime_B; + + return (void *) func; +} + +int +main (void) +{ + const unsigned int ITERS = 10; + + for (int i = ITERS; i > 0; i--) + { + do_it_right_at_runtime (); + } + + if (resolver_fn != 1) + __builtin_abort (); + + if (resolved_fn != 10) + __builtin_abort (); + + return 0; +} |