Commit 5ce97055 by Jan Hubicka Committed by Jan Hubicka

ipa-prop.h (ipa_get_controlled_uses): Add hack to avoid ICE when speculation is added.


	* ipa-prop.h (ipa_get_controlled_uses): Add hack to avoid ICE
	when speculation is added.
	(ipa_edge_args): Add polymorphic_call_contexts.
	(ipa_get_ith_polymorhic_call_context): New accesor.
	(ipa_make_edge_direct_to_target): Add SPECULATIVE parameter.
	* ipa-prop.c (ipa_print_node_jump_functions_for_edge): Print contexts.
	(ipa_compute_jump_functions_for_edge): Compute contexts.
	(update_jump_functions_after_inlining): Update contexts.
	(ipa_make_edge_direct_to_target): Add SPECULATIVE argument;
	update dumping; add speculative edge creation.
	(try_make_edge_direct_virtual_call): Add CTX_PTR parameter; handle
	context updating.
	(update_indirect_edges_after_inlining): Pass down context.
	(ipa_edge_duplication_hook): Duplicate contexts.
	(ipa_write_node_info): Stream out contexts.
	(ipa_read_node_info): Stream in contexts.
	* ipa-devirt.c (type_all_derivations_known_p): Avoid ICE on non-ODR
	types.
	(try_speculative_devirtualization): New function.
	* ipa-utils.h (try_speculative_devirtualization): Declare.

From-SVN: r215794
parent 9fbbb20d
2014-10-01 Jan Hubicka <hubicka@ucw.cz>
* ipa-prop.h (ipa_get_controlled_uses): Add hack to avoid ICE
when speculation is added.
(ipa_edge_args): Add polymorphic_call_contexts.
(ipa_get_ith_polymorhic_call_context): New accesor.
(ipa_make_edge_direct_to_target): Add SPECULATIVE parameter.
* ipa-prop.c (ipa_print_node_jump_functions_for_edge): Print contexts.
(ipa_compute_jump_functions_for_edge): Compute contexts.
(update_jump_functions_after_inlining): Update contexts.
(ipa_make_edge_direct_to_target): Add SPECULATIVE argument;
update dumping; add speculative edge creation.
(try_make_edge_direct_virtual_call): Add CTX_PTR parameter; handle
context updating.
(update_indirect_edges_after_inlining): Pass down context.
(ipa_edge_duplication_hook): Duplicate contexts.
(ipa_write_node_info): Stream out contexts.
(ipa_read_node_info): Stream in contexts.
* ipa-devirt.c (type_all_derivations_known_p): Avoid ICE on non-ODR
types.
(try_speculative_devirtualization): New function.
* ipa-utils.h (try_speculative_devirtualization): Declare.
2014-10-01 Jan Hubicka <hubicka@ucw.cz>
* ipa.c (walk_polymorphic_call_targets): Avoid ICE when
dumping during WPA.
......@@ -224,6 +224,9 @@ type_all_derivations_known_p (const_tree t)
return true;
if (flag_ltrans)
return false;
/* Non-C++ types may have IDENTIFIER_NODE here, do not crash. */
if (!TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) != TYPE_DECL)
return true;
if (type_in_anonymous_namespace_p (t))
return true;
return (decl_function_context (TYPE_NAME (t)) != NULL);
......@@ -2734,6 +2737,43 @@ decl_warning_cmp (const void *p1, const void *p2)
return t2->count - t1->count;
}
/* Try speculatively devirtualize call to OTR_TYPE with OTR_TOKEN with
context CTX. */
struct cgraph_node *
try_speculative_devirtualization (tree otr_type, HOST_WIDE_INT otr_token,
ipa_polymorphic_call_context ctx)
{
vec <cgraph_node *>targets
= possible_polymorphic_call_targets
(otr_type, otr_token, ctx, NULL, NULL, true);
unsigned int i;
struct cgraph_node *likely_target = NULL;
for (i = 0; i < targets.length (); i++)
if (likely_target_p (targets[i]))
{
if (likely_target)
return NULL;
likely_target = targets[i];
}
if (!likely_target
||!likely_target->definition
|| DECL_EXTERNAL (likely_target->decl))
return NULL;
/* Don't use an implicitly-declared destructor (c++/58678). */
struct cgraph_node *non_thunk_target
= likely_target->function_symbol ();
if (DECL_ARTIFICIAL (non_thunk_target->decl))
return NULL;
if (likely_target->get_availability () <= AVAIL_INTERPOSABLE
&& likely_target->can_be_discarded_p ())
return NULL;
return likely_target;
}
/* The ipa-devirt pass.
When polymorphic call has only one likely target in the unit,
turn it into speculative call. */
......
......@@ -432,7 +432,10 @@ ipa_set_param_used (struct ipa_node_params *info, int i, bool val)
static inline int
ipa_get_controlled_uses (struct ipa_node_params *info, int i)
{
return info->descriptors[i].controlled_uses;
/* FIXME: introducing speuclation causes out of bounds access here. */
if (info->descriptors.length () > (unsigned)i)
return info->descriptors[i].controlled_uses;
return IPA_UNDESCRIBED_USE;
}
/* Set the controlled counter of a given parameter. */
......@@ -479,6 +482,7 @@ struct GTY(()) ipa_edge_args
{
/* Vector of the callsite's jump function of each parameter. */
vec<ipa_jump_func, va_gc> *jump_functions;
vec<ipa_polymorphic_call_context, va_gc> *polymorphic_call_contexts;
};
/* ipa_edge_args access functions. Please use these to access fields that
......@@ -502,6 +506,16 @@ ipa_get_ith_jump_func (struct ipa_edge_args *args, int i)
return &(*args->jump_functions)[i];
}
/* Returns a pointer to the polymorphic call context for the ith argument.
NULL if contexts are not computed. */
static inline struct ipa_polymorphic_call_context *
ipa_get_ith_polymorhic_call_context (struct ipa_edge_args *args, int i)
{
if (!args->polymorphic_call_contexts)
return NULL;
return &(*args->polymorphic_call_contexts)[i];
}
/* Types of vectors holding the infos. */
/* Vector where the parameter infos are actually stored. */
......@@ -585,7 +599,8 @@ tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
vec<tree> ,
vec<tree> ,
vec<ipa_agg_jump_function_p> );
struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree);
struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree,
bool speculative = false);
tree ipa_binfo_from_known_type_jfunc (struct ipa_jump_func *);
tree ipa_impossible_devirt_target (struct cgraph_edge *, tree);
......
......@@ -82,6 +82,8 @@ bool contains_polymorphic_type_p (const_tree);
void register_odr_type (tree);
bool types_must_be_same_for_odr (tree, tree);
bool types_odr_comparable (tree, tree);
cgraph_node *try_speculative_devirtualization (tree, HOST_WIDE_INT,
ipa_polymorphic_call_context);
/* Return vector containing possible targets of polymorphic call E.
If COMPLETEP is non-NULL, store true if the list is complette.
......
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