Commit 4d7cf10d by Jan Hubicka Committed by Jan Hubicka

ipa-utils.h (ipa_polymorphic_call_context): Turn into class; add ctors.


	* ipa-utils.h (ipa_polymorphic_call_context): Turn into class; add ctors.
	(possible_polymorphic_call_targets, dump_possible_polymorphic_call_targets,
	possible_polymorphic_call_target_p, possible_polymorphic_call_target_p): Simplify.
	(get_dynamic_type): Remove.
	* ipa-devirt.c (ipa_dummy_polymorphic_call_context): Remove.
	(clear_speculation): Bring to ipa-deivrt.h
	(get_class_context): Rename to ...
	(ipa_polymorphic_call_context::restrict_to_inner_class): ... this one.
	(contains_type_p): Update.
	(get_dynamic_type): Rename to ...
	ipa_polymorphic_call_context::get_dynamic_type(): ... this one.
	(possible_polymorphic_call_targets): UPdate.
	* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Update.
	* ipa-prop.c (ipa_analyze_call_uses): Update.

From-SVN: r214060
parent 1a985ca8
2014-08-15 Jan Hubicka <hubicka@ucw.cz>
* ipa-utils.h (ipa_polymorphic_call_context): Turn into class; add ctors.
(possible_polymorphic_call_targets, dump_possible_polymorphic_call_targets,
possible_polymorphic_call_target_p, possible_polymorphic_call_target_p): Simplify.
(get_dynamic_type): Remove.
* ipa-devirt.c (ipa_dummy_polymorphic_call_context): Remove.
(clear_speculation): Bring to ipa-deivrt.h
(get_class_context): Rename to ...
(ipa_polymorphic_call_context::restrict_to_inner_class): ... this one.
(contains_type_p): Update.
(get_dynamic_type): Rename to ...
ipa_polymorphic_call_context::get_dynamic_type(): ... this one.
(possible_polymorphic_call_targets): UPdate.
* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Update.
* ipa-prop.c (ipa_analyze_call_uses): Update.
2014-08-15 Oleg Endo <olegendo@gcc.gnu.org>
* doc/invoke.texi (SH options): Document missing processor variant
......
......@@ -2356,9 +2356,9 @@ ipa_analyze_call_uses (struct func_body_info *fbi, gimple call)
&otr_type, &otr_token,
&context, call);
if (get_dynamic_type (instance, &context,
OBJ_TYPE_REF_OBJECT (target),
otr_type, call))
if (context.get_dynamic_type (instance,
OBJ_TYPE_REF_OBJECT (target),
otr_type, call))
{
gcc_assert (TREE_CODE (otr_type) == RECORD_TYPE);
cs->indirect_info->polymorphic = true;
......
......@@ -36,7 +36,9 @@ struct ipa_dfs_info {
/* Context of polymorphic call. This is used by ipa-devirt walkers of the
type inheritance graph. */
struct ipa_polymorphic_call_context {
class ipa_polymorphic_call_context {
public:
/* The called object appears in an object of type OUTER_TYPE
at offset OFFSET. When information is not 100% reliable, we
use SPECULATIVE_OUTER_TYPE and SPECULATIVE_OFFSET. */
......@@ -51,10 +53,58 @@ struct ipa_polymorphic_call_context {
/* True if speculative outer object may be of derived type. We always
speculate that construction does not happen. */
bool speculative_maybe_derived_type;
/* Build empty "I know nothing" context. */
ipa_polymorphic_call_context ();
/* Build polymorphic call context for indirect call E. */
ipa_polymorphic_call_context (cgraph_edge *e);
/* Make context non-speculative. */
void clear_speculation ();
/* Walk container types and modify context to point to actual class
containing EXPECTED_TYPE as base class. */
bool restrict_to_inner_class (tree expected_type);
/* Look for vtable stores or constructor calls to work out dynamic type
of memory location. */
bool get_dynamic_type (tree, tree, tree, gimple);
};
/* Context representing "I know nothing". */
extern const ipa_polymorphic_call_context ipa_dummy_polymorphic_call_context;
/* Build polymorphic call context for indirect call E. */
inline
ipa_polymorphic_call_context::ipa_polymorphic_call_context (cgraph_edge *e)
{
offset = e->indirect_info->offset;
speculative_offset = e->indirect_info->speculative_offset;
outer_type = e->indirect_info->outer_type;
speculative_outer_type = e->indirect_info->speculative_outer_type;
maybe_in_construction = e->indirect_info->maybe_in_construction;
maybe_derived_type = e->indirect_info->maybe_derived_type;
speculative_maybe_derived_type = e->indirect_info->speculative_maybe_derived_type;
}
/* Build empty "I know nothing" context. */
inline
ipa_polymorphic_call_context::ipa_polymorphic_call_context ()
: offset(0), speculative_offset(0), outer_type(NULL),
speculative_outer_type(NULL), maybe_in_construction(false),
maybe_derived_type(false), speculative_maybe_derived_type(false)
{
}
/* Make context non-speculative. */
inline void
ipa_polymorphic_call_context::clear_speculation ()
{
speculative_outer_type = NULL;
speculative_offset = 0;
speculative_maybe_derived_type = false;
}
/* In ipa-utils.c */
void ipa_print_order (FILE*, const char *, struct cgraph_node**, int);
......@@ -95,7 +145,6 @@ tree get_polymorphic_call_info (tree, tree, tree *,
HOST_WIDE_INT *,
ipa_polymorphic_call_context *,
gimple call = NULL);
bool get_dynamic_type (tree, ipa_polymorphic_call_context *, tree, tree, gimple);
bool get_polymorphic_call_info_from_invariant (ipa_polymorphic_call_context *,
tree, tree, HOST_WIDE_INT);
bool decl_maybe_in_construction_p (tree, tree, gimple, tree);
......@@ -121,13 +170,7 @@ possible_polymorphic_call_targets (struct cgraph_edge *e,
int *nonconstruction_targets = NULL)
{
gcc_checking_assert (e->indirect_info->polymorphic);
ipa_polymorphic_call_context context = {e->indirect_info->offset,
e->indirect_info->speculative_offset,
e->indirect_info->outer_type,
e->indirect_info->speculative_outer_type,
e->indirect_info->maybe_in_construction,
e->indirect_info->maybe_derived_type,
e->indirect_info->speculative_maybe_derived_type};
ipa_polymorphic_call_context context(e);
return possible_polymorphic_call_targets (e->indirect_info->otr_type,
e->indirect_info->otr_token,
context,
......@@ -163,13 +206,7 @@ inline void
dump_possible_polymorphic_call_targets (FILE *f, struct cgraph_edge *e)
{
gcc_checking_assert (e->indirect_info->polymorphic);
ipa_polymorphic_call_context context = {e->indirect_info->offset,
e->indirect_info->speculative_offset,
e->indirect_info->outer_type,
e->indirect_info->speculative_outer_type,
e->indirect_info->maybe_in_construction,
e->indirect_info->maybe_derived_type,
e->indirect_info->speculative_maybe_derived_type};
ipa_polymorphic_call_context context(e);
dump_possible_polymorphic_call_targets (f, e->indirect_info->otr_type,
e->indirect_info->otr_token,
context);
......@@ -182,11 +219,7 @@ inline bool
possible_polymorphic_call_target_p (struct cgraph_edge *e,
struct cgraph_node *n)
{
ipa_polymorphic_call_context context = {e->indirect_info->offset, 0,
e->indirect_info->outer_type, NULL,
e->indirect_info->maybe_in_construction,
e->indirect_info->maybe_derived_type,
false};
ipa_polymorphic_call_context context(e);
return possible_polymorphic_call_target_p (e->indirect_info->otr_type,
e->indirect_info->otr_token,
context, n);
......@@ -199,10 +232,11 @@ inline bool
possible_polymorphic_call_target_p (tree call,
struct cgraph_node *n)
{
ipa_polymorphic_call_context context;
return possible_polymorphic_call_target_p (obj_type_ref_class (call),
tree_to_uhwi
(OBJ_TYPE_REF_TOKEN (call)),
ipa_dummy_polymorphic_call_context,
context,
n);
}
#endif /* GCC_IPA_UTILS_H */
......
......@@ -4374,8 +4374,7 @@ eliminate_dom_walker::before_dom_children (basic_block b)
fn,
&otr_type, &otr_token, &context, stmt);
get_dynamic_type (instance, &context,
OBJ_TYPE_REF_OBJECT (fn), otr_type, stmt);
context.get_dynamic_type (instance, OBJ_TYPE_REF_OBJECT (fn), otr_type, stmt);
vec <cgraph_node *>targets
= possible_polymorphic_call_targets (obj_type_ref_class (fn),
......
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