diff options
Diffstat (limited to 'gcc/ipa-prop.c')
-rw-r--r-- | gcc/ipa-prop.c | 103 |
1 files changed, 36 insertions, 67 deletions
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 50adefbcde5..febcd0cef87 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -54,6 +54,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-ref.h" #include "cgraph.h" #include "alloc-pool.h" +#include "symbol-summary.h" #include "ipa-prop.h" #include "bitmap.h" #include "gimple-ssa.h" @@ -131,8 +132,8 @@ struct func_body_info unsigned int aa_walked; }; -/* Vector where the parameter infos are actually stored. */ -vec<ipa_node_params> ipa_node_params_vector; +/* Function summary where the parameter infos are actually stored. */ +ipa_node_params_t *ipa_node_params_sum = NULL; /* Vector of IPA-CP transformation data for each clone. */ vec<ipcp_transformation_summary, va_gc> *ipcp_transformations; /* Vector where the parameter infos are actually stored. */ @@ -140,9 +141,7 @@ vec<ipa_edge_args, va_gc> *ipa_edge_args_vector; /* Holders of ipa cgraph hooks: */ static struct cgraph_edge_hook_list *edge_removal_hook_holder; -static struct cgraph_node_hook_list *node_removal_hook_holder; static struct cgraph_2edge_hook_list *edge_duplication_hook_holder; -static struct cgraph_2node_hook_list *node_duplication_hook_holder; static struct cgraph_node_hook_list *function_insertion_hook_holder; /* Description of a reference to an IPA constant. */ @@ -3300,7 +3299,7 @@ ipa_propagate_indirect_call_infos (struct cgraph_edge *cs, bool changed; /* Do nothing if the preparation phase has not been carried out yet (i.e. during early inlining). */ - if (!ipa_node_params_vector.exists ()) + if (!ipa_node_params_sum) return false; gcc_assert (ipa_edge_args_vector); @@ -3340,16 +3339,21 @@ ipa_free_all_edge_args (void) /* Frees all dynamically allocated structures that the param info points to. */ -void -ipa_free_node_params_substructures (struct ipa_node_params *info) +ipa_node_params::~ipa_node_params () { - info->descriptors.release (); - free (info->lattices); + descriptors.release (); + free (lattices); /* Lattice values and their sources are deallocated with their alocation pool. */ - info->known_csts.release (); - info->known_contexts.release (); - memset (info, 0, sizeof (*info)); + known_contexts.release (); + + lattices = NULL; + ipcp_orig_node = NULL; + analysis_done = 0; + node_enqueued = 0; + do_clone_for_all_contexts = 0; + is_all_contexts_clone = 0; + node_dead = 0; } /* Free all ipa_node_params structures. */ @@ -3357,13 +3361,8 @@ ipa_free_node_params_substructures (struct ipa_node_params *info) void ipa_free_all_node_params (void) { - int i; - struct ipa_node_params *info; - - FOR_EACH_VEC_ELT (ipa_node_params_vector, i, info) - ipa_free_node_params_substructures (info); - - ipa_node_params_vector.release (); + delete ipa_node_params_sum; + ipa_node_params_sum = NULL; } /* Grow ipcp_transformations if necessary. */ @@ -3416,26 +3415,11 @@ ipa_edge_removal_hook (struct cgraph_edge *cs, void *data ATTRIBUTE_UNUSED) ipa_free_edge_args_substructures (IPA_EDGE_REF (cs)); } -/* Hook that is called by cgraph.c when a node is removed. */ - -static void -ipa_node_removal_hook (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) -{ - /* During IPA-CP updating we can be called on not-yet analyze clones. */ - if (ipa_node_params_vector.length () > (unsigned)node->uid) - ipa_free_node_params_substructures (IPA_NODE_REF (node)); - if (vec_safe_length (ipcp_transformations) > (unsigned)node->uid) - { - (*ipcp_transformations)[(unsigned)node->uid].agg_values = NULL; - (*ipcp_transformations)[(unsigned)node->uid].alignments = NULL; - } -} - /* Hook that is called by cgraph.c when an edge is duplicated. */ static void ipa_edge_duplication_hook (struct cgraph_edge *src, struct cgraph_edge *dst, - __attribute__((unused)) void *data) + void *) { struct ipa_edge_args *old_args, *new_args; unsigned int i; @@ -3535,18 +3519,23 @@ ipa_edge_duplication_hook (struct cgraph_edge *src, struct cgraph_edge *dst, } } -/* Hook that is called by cgraph.c when a node is duplicated. */ +/* Analyze newly added function into callgraph. */ static void -ipa_node_duplication_hook (struct cgraph_node *src, struct cgraph_node *dst, - ATTRIBUTE_UNUSED void *data) +ipa_add_new_function (cgraph_node *node, void *data ATTRIBUTE_UNUSED) { - struct ipa_node_params *old_info, *new_info; - struct ipa_agg_replacement_value *old_av, *new_av; + if (node->has_gimple_body_p ()) + ipa_analyze_node (node); +} - ipa_check_create_node_params (); - old_info = IPA_NODE_REF (src); - new_info = IPA_NODE_REF (dst); +/* Hook that is called by summary when a node is duplicated. */ + +void +ipa_node_params_t::duplicate(cgraph_node *src, cgraph_node *dst, + ipa_node_params *old_info, + ipa_node_params *new_info) +{ + ipa_agg_replacement_value *old_av, *new_av; new_info->descriptors = old_info->descriptors.copy (); new_info->lattices = NULL; @@ -3587,35 +3576,20 @@ ipa_node_duplication_hook (struct cgraph_node *src, struct cgraph_node *dst, } } - -/* Analyze newly added function into callgraph. */ - -static void -ipa_add_new_function (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) -{ - if (node->has_gimple_body_p ()) - ipa_analyze_node (node); -} - /* Register our cgraph hooks if they are not already there. */ void ipa_register_cgraph_hooks (void) { + ipa_check_create_node_params (); + if (!edge_removal_hook_holder) edge_removal_hook_holder = symtab->add_edge_removal_hook (&ipa_edge_removal_hook, NULL); - if (!node_removal_hook_holder) - node_removal_hook_holder = - symtab->add_cgraph_removal_hook (&ipa_node_removal_hook, NULL); if (!edge_duplication_hook_holder) edge_duplication_hook_holder = symtab->add_edge_duplication_hook (&ipa_edge_duplication_hook, NULL); - if (!node_duplication_hook_holder) - node_duplication_hook_holder = - symtab->add_cgraph_duplication_hook (&ipa_node_duplication_hook, NULL); - if (!function_insertion_hook_holder) - function_insertion_hook_holder = + function_insertion_hook_holder = symtab->add_cgraph_insertion_hook (&ipa_add_new_function, NULL); } @@ -3626,12 +3600,8 @@ ipa_unregister_cgraph_hooks (void) { symtab->remove_edge_removal_hook (edge_removal_hook_holder); edge_removal_hook_holder = NULL; - symtab->remove_cgraph_removal_hook (node_removal_hook_holder); - node_removal_hook_holder = NULL; symtab->remove_edge_duplication_hook (edge_duplication_hook_holder); edge_duplication_hook_holder = NULL; - symtab->remove_cgraph_duplication_hook (node_duplication_hook_holder); - node_duplication_hook_holder = NULL; symtab->remove_cgraph_insertion_hook (function_insertion_hook_holder); function_insertion_hook_holder = NULL; } @@ -4801,8 +4771,7 @@ ipa_prop_write_jump_functions (void) lto_symtab_encoder_iterator lsei; lto_symtab_encoder_t encoder; - - if (!ipa_node_params_vector.exists ()) + if (!ipa_node_params_sum) return; ob = create_output_block (LTO_section_jump_functions); |