devirt-13.C: Update template.

* g++.dg/ipa/devirt-13.C: Update template.
	* ipa-utils.h (possible_polymorphic_call_targets): Determine context of
	the call.
	* gimple-fold.c (gimple_fold_call): Use ipa-devirt to devirtualize.

From-SVN: r206042
This commit is contained in:
Jan Hubicka 2013-12-17 11:26:59 +01:00 committed by Jan Hubicka
parent 2477c234e2
commit 61dd6a2e33
4 changed files with 30 additions and 19 deletions

View File

@ -1,3 +1,9 @@
2013-12-17 Jan Hubicka <hubicka@ucw.cz>
* ipa-utils.h (possible_polymorphic_call_targets): Determine context of
the call.
* gimple-fold.c (gimple_fold_call): Use ipa-devirt to devirtualize.
2013-12-17 Jakub Jelinek <jakub@redhat.com>
* expr.c (convert_modes): For SUBREG_PROMOTED_VAR_P use SUBREG_REG (x)

View File

@ -1153,26 +1153,20 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace)
gimple_call_set_fn (stmt, OBJ_TYPE_REF_EXPR (callee));
changed = true;
}
else if (virtual_method_call_p (callee))
else if (flag_devirtualize && virtual_method_call_p (callee))
{
tree obj = OBJ_TYPE_REF_OBJECT (callee);
tree binfo = gimple_extract_devirt_binfo_from_cst
(obj, obj_type_ref_class (callee));
if (binfo)
bool final;
vec <cgraph_node *>targets
= possible_polymorphic_call_targets (callee, &final);
if (final && targets.length () <= 1)
{
HOST_WIDE_INT token
= TREE_INT_CST_LOW (OBJ_TYPE_REF_TOKEN (callee));
tree fndecl = gimple_get_virt_method_for_binfo (token, binfo);
if (fndecl)
{
#ifdef ENABLE_CHECKING
gcc_assert (possible_polymorphic_call_target_p
(callee, cgraph_get_node (fndecl)));
#endif
gimple_call_set_fndecl (stmt, fndecl);
changed = true;
}
tree fndecl;
if (targets.length () == 1)
fndecl = targets[0]->decl;
else
fndecl = builtin_decl_implicit (BUILT_IN_UNREACHABLE);
gimple_call_set_fndecl (stmt, fndecl);
changed = true;
}
}
}

View File

@ -121,10 +121,17 @@ possible_polymorphic_call_targets (tree call,
bool *final = NULL,
void **cache_token = NULL)
{
tree otr_type;
HOST_WIDE_INT otr_token;
ipa_polymorphic_call_context context;
get_polymorphic_call_info (current_function_decl,
call,
&otr_type, &otr_token, &context);
return possible_polymorphic_call_targets (obj_type_ref_class (call),
tree_to_uhwi
(OBJ_TYPE_REF_TOKEN (call)),
ipa_dummy_polymorphic_call_context,
context,
final, cache_token);
}

View File

@ -1,3 +1,7 @@
2013-12-17 Jan Hubicka <hubicka@ucw.cz>
* g++.dg/ipa/devirt-13.C: Update template.
2013-12-16 Janus Weil <janus@gcc.gnu.org>
PR fortran/54949