From 1caef38b2a80940473a4d63322cd9c37048bc4b5 Mon Sep 17 00:00:00 2001 From: jamborm Date: Thu, 5 Aug 2010 13:23:07 +0000 Subject: 2010-08-05 Martin Jambor * ipa-prop.h (enum ipa_lattice_type): Changed comments. (struct ipa_param_descriptor): New fields types and cannot_devirtualize. (ipa_param_cannot_devirtualize_p): New function. (ipa_param_types_vec_empty): Likewise. (ipa_make_edge_direct_to_target): Declare. * ipa-cp.c: Fixed first stage driver name in initial comment, described devirtualization there too. (ipcp_analyze_node): Call ipa_analyze_params_uses. (ipcp_print_all_lattices): Print devirtualization info. (ipa_set_param_cannot_devirtualize): New function. (ipcp_initialize_node_lattices): Set cannot_devirtualize when setting lattice to BOTTOM. (ipcp_init_stage): Merged into... (ipcp_generate_summary): ...its caller. (ipcp_change_tops_to_bottom): Also process type lists. (ipcp_add_param_type): New function. (ipcp_copy_types): Likewise. (ipcp_propagate_types): Likewise. (ipcp_propagate_stage): Also propagate types. (ipcp_need_redirect_p): Variable jump_func moved to its scope block. Also return true if propagated types require it. (ipcp_update_callgraph): Dump redirection info. (ipcp_process_devirtualization_opportunities): New function. (ipcp_const_param_count): Include known type information. (ipcp_insert_stage): Call ipcp_process_devirtualization_opportunities on new node. Fixed formatting. * ipa-prop.c (make_edge_direct_to_target): Renamed to ipa_make_edge_direct_to_target and changed all callers. Made externally visible. (ipa_node_duplication_hook): Duplicate types vector. * cgraphunit.c (cgraph_redirect_edge_call_stmt_to_callee): Also try to redirect outgoing calls for which we can't get a decl from the statement. Check that we can get a decl from the call statement. * ipa-inline.c (inline_indirect_intraprocedural_analysis): Call ipa_analyze_params_uses only when ipa-cp is disabled. * tree-inline.c (get_indirect_callee_fndecl): Removed. (expand_call_inline): Do not call get_indirect_callee_fndecl. * params.def (PARAM_DEVIRT_TYPE_LIST_SIZE): New parameter. * Makefile.in (ipa-cp.o): Add gimple.h to dependencies. * testsuite/g++.dg/ipa/devirt-1.C: New test. * testsuite/g++.dg/ipa/devirt-2.C: Likewise. * testsuite/g++.dg/ipa/devirt-3.C: Likewise. * testsuite/g++.dg/ipa/devirt-4.C: Likewise. * testsuite/g++.dg/ipa/devirt-5.C: Likewise. * testsuite/gcc.dg/ipa/iinline-3.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162911 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ipa-prop.h | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'gcc/ipa-prop.h') diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h index 2a28aa3ce38..8244a7f79e3 100644 --- a/gcc/ipa-prop.h +++ b/gcc/ipa-prop.h @@ -133,11 +133,12 @@ struct GTY (()) ipa_jump_func computed by the interprocedural stage of IPCP. There are three main values of the lattice: IPA_TOP - unknown, - IPA_BOTTOM - non constant, + IPA_BOTTOM - variable, IPA_CONST_VALUE - simple scalar constant, - Cval of formal f will have a constant value if all callsites to this - function have the same constant value passed to f. - Integer and real constants are represented as IPA_CONST_VALUE. */ + + We also use this type to propagate types accross the call graph for the + purpose of devirtualization. In that case, IPA_CONST_VALUE denotes a known + type, rather than a constant. */ enum ipa_lattice_type { IPA_BOTTOM, @@ -161,8 +162,14 @@ struct ipa_param_descriptor struct ipcp_lattice ipcp_lattice; /* PARAM_DECL of this parameter. */ tree decl; + /* Vector of BINFOs of types that this argument might encounter. NULL + basically means a top value, bottom is marked by the cannot_devirtualize + flag below.*/ + VEC (tree, heap) *types; /* The parameter is used. */ unsigned used : 1; + /* Set when parameter type cannot be used for devirtualization. */ + unsigned cannot_devirtualize : 1; }; /* ipa_node_params stores information related to formal parameters of functions @@ -232,6 +239,25 @@ ipa_is_param_used (struct ipa_node_params *info, int i) return info->params[i].used; } +/* Return the cannot_devirtualize flag corresponding to the Ith formal + parameter of the function associated with INFO. The corresponding function + to set the flag is ipa_set_param_cannot_devirtualize. */ + +static inline bool +ipa_param_cannot_devirtualize_p (struct ipa_node_params *info, int i) +{ + return info->params[i].cannot_devirtualize; +} + +/* Return true iff the vector of possible types of the Ith formal parameter of + the function associated with INFO is empty. */ + +static inline bool +ipa_param_types_vec_empty (struct ipa_node_params *info, int i) +{ + return info->params[i].types == NULL; +} + /* Flag this node as having callers with variable number of arguments. */ static inline void @@ -402,6 +428,10 @@ void ipa_initialize_node_params (struct cgraph_node *node); bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs, VEC (cgraph_edge_p, heap) **new_edges); +/* Indirect edge and binfo processing. */ +struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree); + + /* Debugging interface. */ void ipa_print_node_params (FILE *, struct cgraph_node *node); void ipa_print_all_params (FILE *); -- cgit v1.2.3