This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [middle-end, patch 2/9] Move ipa-prop structures to on-the-side arrays


> 2008-07-03  Martin Jambor  <mjambor@suse.cz>
> 
> 	* ipa-prop.c: Include flags.h.
> 	(GET_ARRAY_SIZE): New macro.
> 	(ipa_node_params_array_size): New variable.
> 	(ipa_node_params_array): New variable.
> 	(ipa_edge_args_array_size): New variable.
> 	(ipa_edge_args_array): New variable.
> 	(ipa_create_node_params): Removed.
> 	(ipa_create_all_node_params): Changed to realloc the on-the-side array.
> 	(ipa_create_all_edge_args): Changed to realloc the on-the-side array.
> 	(ipa_free_edge_args_substructures): New function.
> 	(ipa_free_all_edge_args): Changed to deallocate the on-the-side array.
> 	(ipa_free_node_params_substructures): New function.
> 	(ipa_free_all_node_params): Changed to deallocate the on-the-side array.
> 	(free_all_ipa_structures_after_ipa_cp): New function.
> 	(edge_removal_hook_holder): New variable.
> 	(node_removal_hook_holder): New variable.
> 	(edge_duplication_hook_holder): New variable.
> 	(node_duplication_hook_holder): New variable.
> 	(ipa_edge_removal_hook): New function.
> 	(ipa_node_removal_hook): New function.
> 	(ipa_edge_duplication_hook): New function.
> 	(ipa_node_duplication_hook): New function.
> 	(ipa_register_cgraph_hooks): New function.
> 	(ipa_unregister_cgraph_hooks): New function.
> 	(ipa_detect_param_modifications): Check for presence of modified flags.
> 	(ipa_compute_jump_functions): Check for presence of jump functions.
> 
> 	* ipa-cp.c (ipcp_driver): Allocate infos with 
> 	ipa_check_create_node_params, free them with 
> 	free_all_ipa_structures_after_ipa_cp, call ipa_register_cgraph_hooks.
> 
> 	* ipa-prop.h (IPA_NODE_REF): Changed to access an on-the-side array.
> 	(IPA_EDGE_REF): Changed to access an on-the-side array.
> 	(ipa_check_create_node_params): New function.
> 	(ipa_check_create_edge_args): New function.
> 	
> +#include "flags.h"
> +
> +/* To avoid frequent reallocation the size of arrays is greater than needed,
> +   the number of elements is (not less than) 1.25 * size_wanted.  */
> +#define GET_ARRAY_SIZE(X) ((((X) / 4) + 1) * 5)

We use our VECtor API for this kind of work.  Can you please update the
array to be VEC_* based?
> +  for (i = 0; i < ipa_edge_args_array_size; i++)
> +    {
> +      struct ipa_edge_args *args = &ipa_edge_args_array[i];
> +      ipa_free_edge_args_substructures (args);

Probably better without the temporary :)
> +/* Hook that is called by cgraph.c when an edge is removed.  */
> +static void
> +ipa_edge_removal_hook (struct cgraph_edge *cs, void *data)
								ATTRIBUTE_UNUSED
								here.
> +{
> +  ipa_free_edge_args_substructures (IPA_EDGE_REF (cs));
> +/* Register our cgraph hooks if they are not already there.  */
> +void
> +ipa_register_cgraph_hooks (void)
> +{
> +  if (!edge_removal_hook_holder)
> +    edge_removal_hook_holder =
> +      cgraph_add_edge_removal_hook (&ipa_edge_removal_hook, NULL);

If those are already registered, something is wrong.  I would probalby
do gcc_assert for edge_removal_hook_holder

> +  if (!node_removal_hook_holder)
> +    node_removal_hook_holder =
> +      cgraph_add_node_removal_hook (&ipa_node_removal_hook, NULL);
> +  if (!edge_duplication_hook_holder)
> +    edge_duplication_hook_holder =
> +      cgraph_add_edge_duplication_hook (&ipa_edge_duplication_hook, NULL);
> +  if (!node_duplication_hook_holder)
> +    node_duplication_hook_holder =
> +      cgraph_add_node_duplication_hook (&ipa_node_duplication_hook, NULL);
> +}
> +
> +/* Unregister our cgraph hooks if they are not already there.  */
> +static void
> +ipa_unregister_cgraph_hooks (void)
> +{
> +  cgraph_remove_edge_removal_hook (edge_removal_hook_holder);
> +  edge_removal_hook_holder = NULL;
> +  cgraph_remove_node_removal_hook (node_removal_hook_holder);
> +  node_removal_hook_holder = NULL;
> +  cgraph_remove_edge_duplication_hook (edge_duplication_hook_holder);
> +  edge_duplication_hook_holder = NULL;
> +  cgraph_remove_node_duplication_hook (node_duplication_hook_holder);
> +  node_duplication_hook_holder = NULL;
> +}


Please send updated patch with VECtors.  It is OK otherwise.

Honza


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]