Commit 17a7218b by Martin Liska Committed by Martin Liska

Do not allow to inline ifunc resolvers (PR ipa/81128).

2017-06-28  Martin Liska  <mliska@suse.cz>

	PR ipa/81128
	* ipa-visibility.c (non_local_p): Handle visibility.
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-06-28  Martin Liska  <mliska@suse.cz>

	PR ipa/81128
	* gcc.target/i386/pr81128.c: New test.

From-SVN: r249735
parent 63010089
2017-06-28 Martin Liska <mliska@suse.cz> 2017-06-28 Martin Liska <mliska@suse.cz>
PR ipa/81128
* ipa-visibility.c (non_local_p): Handle visibility.
2017-06-28 Martin Liska <mliska@suse.cz>
PR driver/79659 PR driver/79659
* common.opt: Add IntegerRange to various options. * common.opt: Add IntegerRange to various options.
* opt-functions.awk (integer_range_info): New function. * opt-functions.awk (integer_range_info): New function.
......
2017-06-28 Martin Liska <mliska@suse.cz> 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-06-28 Martin Liska <mliska@suse.cz>
PR driver/79659 PR driver/79659
* c.opt: Add IntegerRange to various options. * c.opt: Add IntegerRange to various options.
......
...@@ -1846,9 +1846,14 @@ handle_alias_ifunc_attribute (bool is_alias, tree *node, tree name, tree args, ...@@ -1846,9 +1846,14 @@ handle_alias_ifunc_attribute (bool is_alias, tree *node, tree name, tree args,
TREE_STATIC (decl) = 1; TREE_STATIC (decl) = 1;
if (!is_alias) if (!is_alias)
/* ifuncs are also aliases, so set that attribute too. */ {
DECL_ATTRIBUTES (decl) /* ifuncs are also aliases, so set that attribute too. */
= tree_cons (get_identifier ("alias"), args, DECL_ATTRIBUTES (decl)); 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 else
{ {
......
...@@ -97,7 +97,8 @@ non_local_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) ...@@ -97,7 +97,8 @@ non_local_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
&& !DECL_EXTERNAL (node->decl) && !DECL_EXTERNAL (node->decl)
&& !node->externally_visible && !node->externally_visible
&& !node->used_from_other_partition && !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. */ /* Return true when function can be marked local. */
......
2017-06-28 Martin Liska <mliska@suse.cz> 2017-06-28 Martin Liska <mliska@suse.cz>
PR ipa/81128
* gcc.target/i386/pr81128.c: New test.
2017-06-28 Martin Liska <mliska@suse.cz>
PR driver/79659 PR driver/79659
* g++.dg/opt/pr79659.C: New test. * g++.dg/opt/pr79659.C: New test.
......
/* 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment