Commit 46a2ab58 by Martin Liska Committed by Martin Liska

Simplify creation of target_clones (PR lto/66295)

2017-02-03  Martin Liska  <mliska@suse.cz>

	PR lto/66295
	* multiple_target.c (create_dispatcher_calls): Redirect edge
	from a caller of a dispatcher.
	(expand_target_clones): Make the clones local.
	(ipa_target_clone): Do both target clones and resolvers.
	(ipa_dispatcher_calls): Remove the pass.
	(pass_dispatcher_calls::gate): Likewise.
	(make_pass_dispatcher_calls): Likewise.
	* passes.def (pass_target_clone): Put as very first IPA early
	pass.
2017-02-03  Martin Liska  <mliska@suse.cz>

	PR lto/66295
	* gcc.target/i386/mvc9.c: New test.

From-SVN: r245155
parent 31a31c9d
2017-02-03 Martin Liska <mliska@suse.cz> 2017-02-03 Martin Liska <mliska@suse.cz>
PR lto/66295
* multiple_target.c (create_dispatcher_calls): Redirect edge
from a caller of a dispatcher.
(expand_target_clones): Make the clones local.
(ipa_target_clone): Do both target clones and resolvers.
(ipa_dispatcher_calls): Remove the pass.
(pass_dispatcher_calls::gate): Likewise.
(make_pass_dispatcher_calls): Likewise.
* passes.def (pass_target_clone): Put as very first IPA early
pass.
2017-02-03 Martin Liska <mliska@suse.cz>
* symtab.c (symtab_node::binds_to_current_def_p): Bail out * symtab.c (symtab_node::binds_to_current_def_p): Bail out
in case of a function with ifunc attribute. in case of a function with ifunc attribute.
......
...@@ -87,6 +87,7 @@ create_dispatcher_calls (struct cgraph_node *node) ...@@ -87,6 +87,7 @@ create_dispatcher_calls (struct cgraph_node *node)
inode->resolve_alias (cgraph_node::get (resolver_decl)); inode->resolve_alias (cgraph_node::get (resolver_decl));
e->redirect_callee (inode); e->redirect_callee (inode);
e->redirect_call_stmt_to_callee ();
/* Since REDIRECT_CALLEE modifies NEXT_CALLER field we move to /* Since REDIRECT_CALLEE modifies NEXT_CALLER field we move to
previously set NEXT_CALLER. */ previously set NEXT_CALLER. */
e = NULL; e = NULL;
...@@ -283,6 +284,7 @@ expand_target_clones (struct cgraph_node *node, bool definition) ...@@ -283,6 +284,7 @@ expand_target_clones (struct cgraph_node *node, bool definition)
create_new_asm_name (attr, suffix); create_new_asm_name (attr, suffix);
/* Create new target clone. */ /* Create new target clone. */
cgraph_node *new_node = create_target_clone (node, definition, suffix); cgraph_node *new_node = create_target_clone (node, definition, suffix);
new_node->local.local = false;
XDELETEVEC (suffix); XDELETEVEC (suffix);
/* Set new attribute for the clone. */ /* Set new attribute for the clone. */
...@@ -334,17 +336,19 @@ expand_target_clones (struct cgraph_node *node, bool definition) ...@@ -334,17 +336,19 @@ expand_target_clones (struct cgraph_node *node, bool definition)
return ret; return ret;
} }
static bool target_clone_pass;
static unsigned int static unsigned int
ipa_target_clone (void) ipa_target_clone (void)
{ {
struct cgraph_node *node; struct cgraph_node *node;
target_clone_pass = false; bool target_clone_pass = false;
FOR_EACH_FUNCTION (node)
target_clone_pass |= expand_target_clones (node, node->definition);
if (target_clone_pass)
FOR_EACH_FUNCTION (node) FOR_EACH_FUNCTION (node)
if (node->definition) create_dispatcher_calls (node);
target_clone_pass |= expand_target_clones (node, true);
return 0; return 0;
} }
...@@ -360,7 +364,7 @@ const pass_data pass_data_target_clone = ...@@ -360,7 +364,7 @@ const pass_data pass_data_target_clone =
0, /* properties_provided */ 0, /* properties_provided */
0, /* properties_destroyed */ 0, /* properties_destroyed */
0, /* todo_flags_start */ 0, /* todo_flags_start */
0 /* todo_flags_finish */ TODO_update_ssa /* todo_flags_finish */
}; };
class pass_target_clone : public simple_ipa_opt_pass class pass_target_clone : public simple_ipa_opt_pass
...@@ -388,58 +392,3 @@ make_pass_target_clone (gcc::context *ctxt) ...@@ -388,58 +392,3 @@ make_pass_target_clone (gcc::context *ctxt)
{ {
return new pass_target_clone (ctxt); return new pass_target_clone (ctxt);
} }
static unsigned int
ipa_dispatcher_calls (void)
{
struct cgraph_node *node;
FOR_EACH_FUNCTION (node)
if (!node->definition)
target_clone_pass |= expand_target_clones (node, false);
if (target_clone_pass)
FOR_EACH_FUNCTION (node)
create_dispatcher_calls (node);
return 0;
}
namespace {
const pass_data pass_data_dispatcher_calls =
{
SIMPLE_IPA_PASS, /* type */
"dispatchercalls", /* name */
OPTGROUP_NONE, /* optinfo_flags */
TV_NONE, /* tv_id */
( PROP_ssa | PROP_cfg ), /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
0 /* todo_flags_finish */
};
class pass_dispatcher_calls : public simple_ipa_opt_pass
{
public:
pass_dispatcher_calls (gcc::context *ctxt)
: simple_ipa_opt_pass (pass_data_dispatcher_calls, ctxt)
{}
/* opt_pass methods: */
virtual bool gate (function *);
virtual unsigned int execute (function *) { return ipa_dispatcher_calls (); }
};
bool
pass_dispatcher_calls::gate (function *)
{
return true;
}
} // anon namespace
simple_ipa_opt_pass *
make_pass_dispatcher_calls (gcc::context *ctxt)
{
return new pass_dispatcher_calls (ctxt);
}
...@@ -136,6 +136,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -136,6 +136,7 @@ along with GCC; see the file COPYING3. If not see
POP_INSERT_PASSES () POP_INSERT_PASSES ()
POP_INSERT_PASSES () POP_INSERT_PASSES ()
NEXT_PASS (pass_target_clone);
NEXT_PASS (pass_ipa_chkp_produce_thunks); NEXT_PASS (pass_ipa_chkp_produce_thunks);
NEXT_PASS (pass_ipa_auto_profile); NEXT_PASS (pass_ipa_auto_profile);
NEXT_PASS (pass_ipa_free_inline_summary); NEXT_PASS (pass_ipa_free_inline_summary);
...@@ -155,7 +156,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -155,7 +156,6 @@ along with GCC; see the file COPYING3. If not see
NEXT_PASS (pass_ipa_devirt); NEXT_PASS (pass_ipa_devirt);
NEXT_PASS (pass_ipa_cp); NEXT_PASS (pass_ipa_cp);
NEXT_PASS (pass_ipa_cdtor_merge); NEXT_PASS (pass_ipa_cdtor_merge);
NEXT_PASS (pass_target_clone);
NEXT_PASS (pass_ipa_hsa); NEXT_PASS (pass_ipa_hsa);
NEXT_PASS (pass_ipa_inline); NEXT_PASS (pass_ipa_inline);
NEXT_PASS (pass_ipa_pure_const); NEXT_PASS (pass_ipa_pure_const);
...@@ -174,7 +174,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -174,7 +174,6 @@ along with GCC; see the file COPYING3. If not see
INSERT_PASSES_AFTER (all_late_ipa_passes) INSERT_PASSES_AFTER (all_late_ipa_passes)
NEXT_PASS (pass_materialize_all_clones); NEXT_PASS (pass_materialize_all_clones);
NEXT_PASS (pass_ipa_pta); NEXT_PASS (pass_ipa_pta);
NEXT_PASS (pass_dispatcher_calls);
NEXT_PASS (pass_omp_simd_clone); NEXT_PASS (pass_omp_simd_clone);
TERMINATE_PASS_LIST (all_late_ipa_passes) TERMINATE_PASS_LIST (all_late_ipa_passes)
......
2017-02-03 Martin Liska <mliska@suse.cz>
PR lto/66295
* gcc.target/i386/mvc9.c: New test.
2017-02-03 Pat Haugen <pthaugen@us.ibm.com> 2017-02-03 Pat Haugen <pthaugen@us.ibm.com>
PR target/79158 PR target/79158
......
/* { dg-do run } */
/* { dg-require-ifunc "" } */
/* { dg-options "-flto -O2" { target lto } } */
__attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
int
foo ()
{
return -2;
}
int
bar ()
{
return 2;
}
int
main ()
{
int r = 0;
r += bar ();
r += foo ();
r += bar ();
r += foo ();
r += bar ();
return r - 2;
}
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