diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2014-09-20 08:22:58 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2014-09-20 06:22:58 +0000 |
commit | 6f8091fc3ed9d3cfa7a6dee7e9f9a34eb4308b2a (patch) | |
tree | 369013d698ddb409805fffaae30510b6caa5d22f /gcc/ipa-utils.h | |
parent | 8e1ba78f1b8eedd6c65c6f0e6d6d09a801de5d3d (diff) | |
download | gcc-6f8091fc3ed9d3cfa7a6dee7e9f9a34eb4308b2a.zip gcc-6f8091fc3ed9d3cfa7a6dee7e9f9a34eb4308b2a.tar.gz gcc-6f8091fc3ed9d3cfa7a6dee7e9f9a34eb4308b2a.tar.bz2 |
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: r215418
Diffstat (limited to 'gcc/ipa-utils.h')
-rw-r--r-- | gcc/ipa-utils.h | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h index 9c81d5c..c81232c 100644 --- a/gcc/ipa-utils.h +++ b/gcc/ipa-utils.h @@ -53,12 +53,28 @@ public: /* True if speculative outer object may be of derived type. We always speculate that construction does not happen. */ bool speculative_maybe_derived_type; + /* True if the context is invalid and all calls should be redirected + to BUILTIN_UNREACHABLE. */ + bool invalid; /* 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); + /* Build polymorphic call context for IP invariant CST. + If specified, OTR_TYPE specify the type of polymorphic call + that takes CST+OFFSET as a prameter. */ + ipa_polymorphic_call_context (tree cst, tree otr_type = NULL, + HOST_WIDE_INT offset = 0); + /* Build context for pointer REF contained in FNDECL at statement STMT. + if INSTANCE is non-NULL, return pointer to the object described by + the context. */ + ipa_polymorphic_call_context (tree fndecl, tree ref, gimple stmt, + tree *instance = NULL); + + /* Look for vtable stores or constructor calls to work out dynamic type + of memory location. */ + bool get_dynamic_type (tree, tree, tree, gimple); /* Make context non-speculative. */ void clear_speculation (); @@ -67,9 +83,9 @@ public: 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); +private: + void set_by_decl (tree, HOST_WIDE_INT); + bool set_by_invariant (tree, tree, HOST_WIDE_INT); }; /* Build polymorphic call context for indirect call E. */ @@ -77,6 +93,8 @@ public: inline ipa_polymorphic_call_context::ipa_polymorphic_call_context (cgraph_edge *e) { + gcc_checking_assert (e->indirect_info->polymorphic); + offset = e->indirect_info->offset; speculative_offset = e->indirect_info->speculative_offset; outer_type = e->indirect_info->outer_type; @@ -84,16 +102,22 @@ ipa_polymorphic_call_context::ipa_polymorphic_call_context (cgraph_edge *e) 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; + invalid = false; } /* 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) { + offset = 0; + speculative_offset = 0; + outer_type = NULL; + speculative_outer_type = NULL; + maybe_in_construction = true; + maybe_derived_type = true; + speculative_maybe_derived_type = false; + invalid = false; } /* Make context non-speculative. */ @@ -131,22 +155,17 @@ void update_type_inheritance_graph (void); vec <cgraph_node *> possible_polymorphic_call_targets (tree, HOST_WIDE_INT, ipa_polymorphic_call_context, - bool *final = NULL, + bool *copletep = NULL, void **cache_token = NULL, int *nonconstruction_targets = NULL); odr_type get_odr_type (tree, bool insert = false); +bool possible_polymorphic_call_target_p (tree ref, gimple stmt, struct cgraph_node *n); void dump_possible_polymorphic_call_targets (FILE *, tree, HOST_WIDE_INT, const ipa_polymorphic_call_context &); bool possible_polymorphic_call_target_p (tree, HOST_WIDE_INT, const ipa_polymorphic_call_context &, struct cgraph_node *); tree method_class_type (const_tree); -tree get_polymorphic_call_info (tree, tree, tree *, - HOST_WIDE_INT *, - ipa_polymorphic_call_context *, - gimple call = NULL); -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); tree vtable_pointer_value_to_binfo (const_tree); bool vtable_pointer_value_to_vtable (const_tree, tree *, unsigned HOST_WIDE_INT *); @@ -155,7 +174,7 @@ bool contains_polymorphic_type_p (const_tree); void register_odr_type (tree); /* Return vector containing possible targets of polymorphic call E. - If FINALP is non-NULL, store true if the list is complette. + If COMPLETEP is non-NULL, store true if the list is complette. CACHE_TOKEN (if non-NULL) will get stored to an unique ID of entry in the target cache. If user needs to visit every target list just once, it can memoize them. @@ -166,16 +185,16 @@ void register_odr_type (tree); inline vec <cgraph_node *> possible_polymorphic_call_targets (struct cgraph_edge *e, - bool *final = NULL, + bool *completep = NULL, void **cache_token = NULL, int *nonconstruction_targets = NULL) { - gcc_checking_assert (e->indirect_info->polymorphic); ipa_polymorphic_call_context context(e); + return possible_polymorphic_call_targets (e->indirect_info->otr_type, e->indirect_info->otr_token, context, - final, cache_token, + completep, cache_token, nonconstruction_targets); } @@ -184,21 +203,16 @@ possible_polymorphic_call_targets (struct cgraph_edge *e, inline vec <cgraph_node *> possible_polymorphic_call_targets (tree ref, gimple call, - bool *final = NULL, + bool *completep = NULL, void **cache_token = NULL) { - tree otr_type; - HOST_WIDE_INT otr_token; - ipa_polymorphic_call_context context; + ipa_polymorphic_call_context context (current_function_decl, ref, call); - get_polymorphic_call_info (current_function_decl, - ref, - &otr_type, &otr_token, &context, call); return possible_polymorphic_call_targets (obj_type_ref_class (ref), tree_to_uhwi (OBJ_TYPE_REF_TOKEN (ref)), context, - final, cache_token); + completep, cache_token); } /* Dump possible targets of a polymorphic call E into F. */ @@ -206,8 +220,8 @@ possible_polymorphic_call_targets (tree ref, 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); + dump_possible_polymorphic_call_targets (f, e->indirect_info->otr_type, e->indirect_info->otr_token, context); @@ -221,26 +235,12 @@ possible_polymorphic_call_target_p (struct cgraph_edge *e, struct cgraph_node *n) { ipa_polymorphic_call_context context(e); + return possible_polymorphic_call_target_p (e->indirect_info->otr_type, e->indirect_info->otr_token, context, n); } -/* Return true if N can be possibly target of a polymorphic call of - OBJ_TYPE_REF expression CALL. */ - -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)), - context, - n); -} - /* Return true of T is type with One Definition Rule info attached. It means that either it is anonymous type or it has assembler name set. */ |