diff options
author | Jan Hubicka <jh@suse.cz> | 2013-11-19 11:05:54 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2013-11-19 10:05:54 +0000 |
commit | 68377e53bdbabc3c328a027bfa2c6a55c0718e81 (patch) | |
tree | c0b5c5a3a1faceb961648fb593887aa1fdf1fc1b /gcc/ipa-utils.h | |
parent | d345bb301ad3ebfce372ce11cc9a6adc35e79e8b (diff) | |
download | gcc-68377e53bdbabc3c328a027bfa2c6a55c0718e81.zip gcc-68377e53bdbabc3c328a027bfa2c6a55c0718e81.tar.gz gcc-68377e53bdbabc3c328a027bfa2c6a55c0718e81.tar.bz2 |
cgraph.c (cgraph_create_indirect_edge): Use get_polymorphic_call_info.
* cgraph.c (cgraph_create_indirect_edge): Use get_polymorphic_call_info.
* cgraph.h (cgraph_indirect_call_info): Add outer_type, maybe_in_construction
and maybe_derived_type.
* ipa-utils.h (ipa_polymorphic_call_context): New structure.
(ipa_dummy_polymorphic_call_context): New global var.
(possible_polymorphic_call_targets): Add context paramter.
(dump_possible_polymorphic_call_targets): Likewise; update
wrappers.
(possible_polymorphic_call_target_p): Likewise.
(get_polymorphic_call_info): New function.
* ipa-devirt.c (ipa_dummy_polymorphic_call_context): New function.
(add_type_duplicate): Remove forgotten debug output.
(method_class_type): Add sanity check.
(maybe_record_node): Add FINALP parameter.
(record_binfo): Add OUTER_TYPE and OFFSET; walk the inner
by info by get_binfo_at_offset.
(possible_polymorphic_call_targets_1): Add OUTER_TYPE/OFFSET parameters;
pass them to record-binfo.
(polymorphic_call_target_d): Add context and FINAL.
(polymorphic_call_target_hasher::hash): Hash context.
(polymorphic_call_target_hasher::equal): Compare context.
(free_polymorphic_call_targets_hash):
(get_class_context): New function.
(contains_type_p): New function.
(get_polymorphic_call_info): New function.
(walk_bases): New function.
(possible_polymorphic_call_targets): Add context parameter; honnor it.
(dump_possible_polymorphic_call_targets): Dump context.
(possible_polymorphic_call_target_p): Add context.
(update_type_inheritance_graph): Update comment.s
(ipa_set_jf_known_type): Assert that compoentn type is known.
(ipa_note_param_call): Do not tamper with offsets.
(ipa_analyze_indirect_call_uses): When offset is being changed; clear
outer type.
(update_indirect_edges_after_inlining): Likewise.
(ipa_write_indirect_edge_info): Stream new fields.
(ipa_read_indirect_edge_info): Stream in new fields.
* ipa/devirt9.C: Verify that the optimization happens already before.
whole-program.
From-SVN: r205019
Diffstat (limited to 'gcc/ipa-utils.h')
-rw-r--r-- | gcc/ipa-utils.h | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h index ca8b872..b527425 100644 --- a/gcc/ipa-utils.h +++ b/gcc/ipa-utils.h @@ -34,6 +34,21 @@ struct ipa_dfs_info { PTR aux; }; +/* Context of polymorphic call. This is used by ipa-devirt walkers of the + type inheritance graph. */ +struct ipa_polymorphic_call_context { + /* The called object appears in an object of type OUTER_TYPE + at offset OFFSET. */ + HOST_WIDE_INT offset; + tree outer_type; + /* True if outer object may be in construction or destruction. */ + bool maybe_in_construction; + /* True if outer object may be of derived type. */ + bool maybe_derived_type; +}; + +/* Context representing "I know nothing". */ +extern const ipa_polymorphic_call_context ipa_dummy_polymorphic_call_context; /* In ipa-utils.c */ void ipa_print_order (FILE*, const char *, struct cgraph_node**, int); @@ -59,13 +74,19 @@ void build_type_inheritance_graph (void); void update_type_inheritance_graph (void); vec <cgraph_node *> possible_polymorphic_call_targets (tree, HOST_WIDE_INT, + ipa_polymorphic_call_context, bool *final = NULL, void **cache_token = NULL); odr_type get_odr_type (tree, bool insert = false); -void dump_possible_polymorphic_call_targets (FILE *, tree, HOST_WIDE_INT); +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 *n); tree method_class_type (tree); +tree get_polymorphic_call_info (tree, tree, tree *, + HOST_WIDE_INT *, + ipa_polymorphic_call_context *); /* Return vector containing possible targets of polymorphic call E. If FINALP is non-NULL, store true if the list is complette. @@ -83,8 +104,27 @@ possible_polymorphic_call_targets (struct cgraph_edge *e, void **cache_token = NULL) { gcc_checking_assert (e->indirect_info->polymorphic); + ipa_polymorphic_call_context context = {e->indirect_info->offset, + e->indirect_info->outer_type, + e->indirect_info->maybe_in_construction, + e->indirect_info->maybe_derived_type}; return possible_polymorphic_call_targets (e->indirect_info->otr_type, e->indirect_info->otr_token, + context, + final, cache_token); +} + +/* Same as above but taking OBJ_TYPE_REF as an parameter. */ + +inline vec <cgraph_node *> +possible_polymorphic_call_targets (tree call, + bool *final = NULL, + void **cache_token = NULL) +{ + return possible_polymorphic_call_targets (obj_type_ref_class (call), + tree_to_uhwi + (OBJ_TYPE_REF_TOKEN (call)), + ipa_dummy_polymorphic_call_context, final, cache_token); } @@ -94,8 +134,13 @@ 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->outer_type, + e->indirect_info->maybe_in_construction, + e->indirect_info->maybe_derived_type}; dump_possible_polymorphic_call_targets (f, e->indirect_info->otr_type, - e->indirect_info->otr_token); + e->indirect_info->otr_token, + context); } /* Return true if N can be possibly target of a polymorphic call of @@ -105,8 +150,13 @@ inline bool possible_polymorphic_call_target_p (struct cgraph_edge *e, struct cgraph_node *n) { + ipa_polymorphic_call_context context = {e->indirect_info->offset, + e->indirect_info->outer_type, + e->indirect_info->maybe_in_construction, + e->indirect_info->maybe_derived_type}; return possible_polymorphic_call_target_p (e->indirect_info->otr_type, - e->indirect_info->otr_token, n); + e->indirect_info->otr_token, + context, n); } /* Return true if N can be possibly target of a polymorphic call of @@ -118,7 +168,8 @@ possible_polymorphic_call_target_p (tree call, { return possible_polymorphic_call_target_p (obj_type_ref_class (call), tree_to_uhwi - (OBJ_TYPE_REF_TOKEN (call)), + (OBJ_TYPE_REF_TOKEN (call)), + ipa_dummy_polymorphic_call_context, n); } #endif /* GCC_IPA_UTILS_H */ |