+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)
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;
}
}
}
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);
}