Commit 606d9a09 by Martin Jambor Committed by Martin Jambor

ipa-prop.h (ipa_jump_func_t): New typedef.

2011-09-03  Martin Jambor  <mjambor@suse.cz>

	* ipa-prop.h (ipa_jump_func_t): New typedef.
	(struct ipa_edge_args): Removed field argument_count, field
	jump_functions turned into a vector.
	(ipa_set_cs_argument_count): Removed.
	(ipa_get_cs_argument_count): Updated to work on vectors.
	(ipa_get_ith_jump_func): Likewise.
	* ipa-prop.c (ipa_count_arguments): Removed.
	(compute_scalar_jump_functions): Use ipa_get_ith_jump_func to access
	jump functions.  Update caller.
	(compute_pass_through_member_ptrs): Likewise.
	(compute_cst_member_ptr_arguments): Likewise.
	(ipa_compute_jump_functions_for_edge): Get number of arguments from
	the statement, allocate vector.
	(ipa_compute_jump_functions): Do not call ipa_count_arguments.
	(duplicate_ipa_jump_func_array): Removed.
	(ipa_edge_duplication_hook): Use VEC_copy, do not copy argument count.
	(ipa_read_node_info): Allocate vector.

From-SVN: r178502
parent 8f15b605
2011-09-03 Martin Jambor <mjambor@suse.cz>
* ipa-prop.h (ipa_jump_func_t): New typedef.
(struct ipa_edge_args): Removed field argument_count, field
jump_functions turned into a vector.
(ipa_set_cs_argument_count): Removed.
(ipa_get_cs_argument_count): Updated to work on vectors.
(ipa_get_ith_jump_func): Likewise.
* ipa-prop.c (ipa_count_arguments): Removed.
(compute_scalar_jump_functions): Use ipa_get_ith_jump_func to access
jump functions. Update caller.
(compute_pass_through_member_ptrs): Likewise.
(compute_cst_member_ptr_arguments): Likewise.
(ipa_compute_jump_functions_for_edge): Get number of arguments from
the statement, allocate vector.
(ipa_compute_jump_functions): Do not call ipa_count_arguments.
(duplicate_ipa_jump_func_array): Removed.
(ipa_edge_duplication_hook): Use VEC_copy, do not copy argument count.
(ipa_read_node_info): Allocate vector.
2011-09-03 John David Anglin <dave.anglin@nrc-cnrc.gc.ca> 2011-09-03 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
PR middle-end/50232 PR middle-end/50232
...@@ -143,25 +143,6 @@ ipa_initialize_node_params (struct cgraph_node *node) ...@@ -143,25 +143,6 @@ ipa_initialize_node_params (struct cgraph_node *node)
} }
} }
/* Count number of arguments callsite CS has and store it in
ipa_edge_args structure corresponding to this callsite. */
static void
ipa_count_arguments (struct cgraph_edge *cs)
{
gimple stmt;
int arg_num;
stmt = cs->call_stmt;
gcc_assert (is_gimple_call (stmt));
arg_num = gimple_call_num_args (stmt);
if (VEC_length (ipa_edge_args_t, ipa_edge_args_vector)
<= (unsigned) cgraph_edge_max_uid)
VEC_safe_grow_cleared (ipa_edge_args_t, gc,
ipa_edge_args_vector, cgraph_edge_max_uid + 1);
ipa_set_cs_argument_count (IPA_EDGE_REF (cs), arg_num);
}
/* Print the jump functions associated with call graph edge CS to file F. */ /* Print the jump functions associated with call graph edge CS to file F. */
static void static void
...@@ -696,7 +677,7 @@ compute_known_type_jump_func (tree op, struct ipa_jump_func *jfunc, ...@@ -696,7 +677,7 @@ compute_known_type_jump_func (tree op, struct ipa_jump_func *jfunc,
static void static void
compute_scalar_jump_functions (struct ipa_node_params *info, compute_scalar_jump_functions (struct ipa_node_params *info,
struct ipa_jump_func *functions, struct ipa_edge_args *args,
gimple call) gimple call)
{ {
tree arg; tree arg;
...@@ -704,12 +685,13 @@ compute_scalar_jump_functions (struct ipa_node_params *info, ...@@ -704,12 +685,13 @@ compute_scalar_jump_functions (struct ipa_node_params *info,
for (num = 0; num < gimple_call_num_args (call); num++) for (num = 0; num < gimple_call_num_args (call); num++)
{ {
struct ipa_jump_func *jfunc = ipa_get_ith_jump_func (args, num);
arg = gimple_call_arg (call, num); arg = gimple_call_arg (call, num);
if (is_gimple_ip_invariant (arg)) if (is_gimple_ip_invariant (arg))
{ {
functions[num].type = IPA_JF_CONST; jfunc->type = IPA_JF_CONST;
functions[num].value.constant = arg; jfunc->value.constant = arg;
} }
else if (TREE_CODE (arg) == SSA_NAME) else if (TREE_CODE (arg) == SSA_NAME)
{ {
...@@ -718,26 +700,24 @@ compute_scalar_jump_functions (struct ipa_node_params *info, ...@@ -718,26 +700,24 @@ compute_scalar_jump_functions (struct ipa_node_params *info,
int index = ipa_get_param_decl_index (info, SSA_NAME_VAR (arg)); int index = ipa_get_param_decl_index (info, SSA_NAME_VAR (arg));
if (index >= 0 if (index >= 0
&& !detect_type_change_ssa (arg, call, &functions[num])) && !detect_type_change_ssa (arg, call, jfunc))
{ {
functions[num].type = IPA_JF_PASS_THROUGH; jfunc->type = IPA_JF_PASS_THROUGH;
functions[num].value.pass_through.formal_id = index; jfunc->value.pass_through.formal_id = index;
functions[num].value.pass_through.operation = NOP_EXPR; jfunc->value.pass_through.operation = NOP_EXPR;
} }
} }
else else
{ {
gimple stmt = SSA_NAME_DEF_STMT (arg); gimple stmt = SSA_NAME_DEF_STMT (arg);
if (is_gimple_assign (stmt)) if (is_gimple_assign (stmt))
compute_complex_assign_jump_func (info, &functions[num], compute_complex_assign_jump_func (info, jfunc, call, stmt, arg);
call, stmt, arg);
else if (gimple_code (stmt) == GIMPLE_PHI) else if (gimple_code (stmt) == GIMPLE_PHI)
compute_complex_ancestor_jump_func (info, &functions[num], compute_complex_ancestor_jump_func (info, jfunc, call, stmt);
call, stmt);
} }
} }
else else
compute_known_type_jump_func (arg, &functions[num], call); compute_known_type_jump_func (arg, jfunc, call);
} }
} }
...@@ -821,7 +801,7 @@ is_parm_modified_before_call (struct param_analysis_info *parm_info, ...@@ -821,7 +801,7 @@ is_parm_modified_before_call (struct param_analysis_info *parm_info,
static bool static bool
compute_pass_through_member_ptrs (struct ipa_node_params *info, compute_pass_through_member_ptrs (struct ipa_node_params *info,
struct param_analysis_info *parms_info, struct param_analysis_info *parms_info,
struct ipa_jump_func *functions, struct ipa_edge_args *args,
gimple call) gimple call)
{ {
bool undecided_members = false; bool undecided_members = false;
...@@ -841,9 +821,11 @@ compute_pass_through_member_ptrs (struct ipa_node_params *info, ...@@ -841,9 +821,11 @@ compute_pass_through_member_ptrs (struct ipa_node_params *info,
gcc_assert (index >=0); gcc_assert (index >=0);
if (!is_parm_modified_before_call (&parms_info[index], call, arg)) if (!is_parm_modified_before_call (&parms_info[index], call, arg))
{ {
functions[num].type = IPA_JF_PASS_THROUGH; struct ipa_jump_func *jfunc = ipa_get_ith_jump_func (args,
functions[num].value.pass_through.formal_id = index; num);
functions[num].value.pass_through.operation = NOP_EXPR; jfunc->type = IPA_JF_PASS_THROUGH;
jfunc->value.pass_through.formal_id = index;
jfunc->value.pass_through.operation = NOP_EXPR;
} }
else else
undecided_members = true; undecided_members = true;
...@@ -969,7 +951,7 @@ determine_cst_member_ptr (gimple call, tree arg, tree method_field, ...@@ -969,7 +951,7 @@ determine_cst_member_ptr (gimple call, tree arg, tree method_field,
associated with the call. */ associated with the call. */
static void static void
compute_cst_member_ptr_arguments (struct ipa_jump_func *functions, compute_cst_member_ptr_arguments (struct ipa_edge_args *args,
gimple call) gimple call)
{ {
unsigned num; unsigned num;
...@@ -977,13 +959,13 @@ compute_cst_member_ptr_arguments (struct ipa_jump_func *functions, ...@@ -977,13 +959,13 @@ compute_cst_member_ptr_arguments (struct ipa_jump_func *functions,
for (num = 0; num < gimple_call_num_args (call); num++) for (num = 0; num < gimple_call_num_args (call); num++)
{ {
struct ipa_jump_func *jfunc = ipa_get_ith_jump_func (args, num);
arg = gimple_call_arg (call, num); arg = gimple_call_arg (call, num);
if (functions[num].type == IPA_JF_UNKNOWN if (jfunc->type == IPA_JF_UNKNOWN
&& type_like_member_ptr_p (TREE_TYPE (arg), &method_field, && type_like_member_ptr_p (TREE_TYPE (arg), &method_field,
&delta_field)) &delta_field))
determine_cst_member_ptr (call, arg, method_field, delta_field, determine_cst_member_ptr (call, arg, method_field, delta_field, jfunc);
&functions[num]);
} }
} }
...@@ -996,29 +978,25 @@ ipa_compute_jump_functions_for_edge (struct param_analysis_info *parms_info, ...@@ -996,29 +978,25 @@ ipa_compute_jump_functions_for_edge (struct param_analysis_info *parms_info,
struct cgraph_edge *cs) struct cgraph_edge *cs)
{ {
struct ipa_node_params *info = IPA_NODE_REF (cs->caller); struct ipa_node_params *info = IPA_NODE_REF (cs->caller);
struct ipa_edge_args *arguments = IPA_EDGE_REF (cs); struct ipa_edge_args *args = IPA_EDGE_REF (cs);
gimple call; gimple call = cs->call_stmt;
int arg_num = gimple_call_num_args (call);
if (ipa_get_cs_argument_count (arguments) == 0 || arguments->jump_functions) if (arg_num == 0 || args->jump_functions)
return; return;
arguments->jump_functions = ggc_alloc_cleared_vec_ipa_jump_func VEC_safe_grow_cleared (ipa_jump_func_t, gc, args->jump_functions, arg_num);
(ipa_get_cs_argument_count (arguments));
call = cs->call_stmt;
gcc_assert (is_gimple_call (call));
/* We will deal with constants and SSA scalars first: */ /* We will deal with constants and SSA scalars first: */
compute_scalar_jump_functions (info, arguments->jump_functions, call); compute_scalar_jump_functions (info, args, call);
/* Let's check whether there are any potential member pointers and if so, /* Let's check whether there are any potential member pointers and if so,
whether we can determine their functions as pass_through. */ whether we can determine their functions as pass_through. */
if (!compute_pass_through_member_ptrs (info, parms_info, if (!compute_pass_through_member_ptrs (info, parms_info, args, call))
arguments->jump_functions, call))
return; return;
/* Finally, let's check whether we actually pass a new constant member /* Finally, let's check whether we actually pass a new constant member
pointer here... */ pointer here... */
compute_cst_member_ptr_arguments (arguments->jump_functions, call); compute_cst_member_ptr_arguments (args, call);
} }
/* Compute jump functions for all edges - both direct and indirect - outgoing /* Compute jump functions for all edges - both direct and indirect - outgoing
...@@ -1038,15 +1016,11 @@ ipa_compute_jump_functions (struct cgraph_node *node, ...@@ -1038,15 +1016,11 @@ ipa_compute_jump_functions (struct cgraph_node *node,
functions unless they may become known during lto/whopr. */ functions unless they may become known during lto/whopr. */
if (!callee->analyzed && !flag_lto) if (!callee->analyzed && !flag_lto)
continue; continue;
ipa_count_arguments (cs);
ipa_compute_jump_functions_for_edge (parms_info, cs); ipa_compute_jump_functions_for_edge (parms_info, cs);
} }
for (cs = node->indirect_calls; cs; cs = cs->next_callee) for (cs = node->indirect_calls; cs; cs = cs->next_callee)
{ ipa_compute_jump_functions_for_edge (parms_info, cs);
ipa_count_arguments (cs);
ipa_compute_jump_functions_for_edge (parms_info, cs);
}
} }
/* If RHS looks like a rhs of a statement loading pfn from a member /* If RHS looks like a rhs of a statement loading pfn from a member
...@@ -1900,19 +1874,6 @@ ipa_node_removal_hook (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) ...@@ -1900,19 +1874,6 @@ ipa_node_removal_hook (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
ipa_free_node_params_substructures (IPA_NODE_REF (node)); ipa_free_node_params_substructures (IPA_NODE_REF (node));
} }
static struct ipa_jump_func *
duplicate_ipa_jump_func_array (const struct ipa_jump_func * src, size_t n)
{
struct ipa_jump_func *p;
if (!src)
return NULL;
p = ggc_alloc_vec_ipa_jump_func (n);
memcpy (p, src, n * sizeof (struct ipa_jump_func));
return p;
}
/* Hook that is called by cgraph.c when a node is duplicated. */ /* Hook that is called by cgraph.c when a node is duplicated. */
static void static void
...@@ -1920,17 +1881,14 @@ ipa_edge_duplication_hook (struct cgraph_edge *src, struct cgraph_edge *dst, ...@@ -1920,17 +1881,14 @@ ipa_edge_duplication_hook (struct cgraph_edge *src, struct cgraph_edge *dst,
__attribute__((unused)) void *data) __attribute__((unused)) void *data)
{ {
struct ipa_edge_args *old_args, *new_args; struct ipa_edge_args *old_args, *new_args;
int arg_count;
ipa_check_create_edge_args (); ipa_check_create_edge_args ();
old_args = IPA_EDGE_REF (src); old_args = IPA_EDGE_REF (src);
new_args = IPA_EDGE_REF (dst); new_args = IPA_EDGE_REF (dst);
arg_count = ipa_get_cs_argument_count (old_args); new_args->jump_functions = VEC_copy (ipa_jump_func_t, gc,
ipa_set_cs_argument_count (new_args, arg_count); old_args->jump_functions);
new_args->jump_functions =
duplicate_ipa_jump_func_array (old_args->jump_functions, arg_count);
if (iinlining_processed_edges if (iinlining_processed_edges
&& bitmap_bit_p (iinlining_processed_edges, src->uid)) && bitmap_bit_p (iinlining_processed_edges, src->uid))
...@@ -2802,12 +2760,10 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node, ...@@ -2802,12 +2760,10 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node,
struct ipa_edge_args *args = IPA_EDGE_REF (e); struct ipa_edge_args *args = IPA_EDGE_REF (e);
int count = streamer_read_uhwi (ib); int count = streamer_read_uhwi (ib);
ipa_set_cs_argument_count (args, count);
if (!count) if (!count)
continue; continue;
VEC_safe_grow_cleared (ipa_jump_func_t, gc, args->jump_functions, count);
args->jump_functions = ggc_alloc_cleared_vec_ipa_jump_func
(ipa_get_cs_argument_count (args));
for (k = 0; k < ipa_get_cs_argument_count (args); k++) for (k = 0; k < ipa_get_cs_argument_count (args); k++)
ipa_read_jump_function (ib, ipa_get_ith_jump_func (args, k), data_in); ipa_read_jump_function (ib, ipa_get_ith_jump_func (args, k), data_in);
} }
...@@ -2816,13 +2772,13 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node, ...@@ -2816,13 +2772,13 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node,
struct ipa_edge_args *args = IPA_EDGE_REF (e); struct ipa_edge_args *args = IPA_EDGE_REF (e);
int count = streamer_read_uhwi (ib); int count = streamer_read_uhwi (ib);
ipa_set_cs_argument_count (args, count);
if (count) if (count)
{ {
args->jump_functions = ggc_alloc_cleared_vec_ipa_jump_func VEC_safe_grow_cleared (ipa_jump_func_t, gc, args->jump_functions,
(ipa_get_cs_argument_count (args)); count);
for (k = 0; k < ipa_get_cs_argument_count (args); k++) for (k = 0; k < ipa_get_cs_argument_count (args); k++)
ipa_read_jump_function (ib, ipa_get_ith_jump_func (args, k), data_in); ipa_read_jump_function (ib, ipa_get_ith_jump_func (args, k),
data_in);
} }
ipa_read_indirect_edge_info (ib, data_in, e); ipa_read_indirect_edge_info (ib, data_in, e);
} }
......
...@@ -119,7 +119,7 @@ struct GTY(()) ipa_member_ptr_cst ...@@ -119,7 +119,7 @@ struct GTY(()) ipa_member_ptr_cst
/* A jump function for a callsite represents the values passed as actual /* A jump function for a callsite represents the values passed as actual
arguments of the callsite. See enum jump_func_type for the various arguments of the callsite. See enum jump_func_type for the various
types of jump functions supported. */ types of jump functions supported. */
struct GTY (()) ipa_jump_func typedef struct GTY (()) ipa_jump_func
{ {
enum jump_func_type type; enum jump_func_type type;
/* Represents a value of a jump function. pass_through is used only in jump /* Represents a value of a jump function. pass_through is used only in jump
...@@ -133,7 +133,10 @@ struct GTY (()) ipa_jump_func ...@@ -133,7 +133,10 @@ struct GTY (()) ipa_jump_func
struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through; struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor; struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor;
} GTY ((desc ("%1.type"))) value; } GTY ((desc ("%1.type"))) value;
}; } ipa_jump_func_t;
DEF_VEC_O (ipa_jump_func_t);
DEF_VEC_ALLOC_O (ipa_jump_func_t, gc);
/* Summary describing a single formal parameter. */ /* Summary describing a single formal parameter. */
...@@ -223,31 +226,19 @@ ipa_is_param_used (struct ipa_node_params *info, int i) ...@@ -223,31 +226,19 @@ ipa_is_param_used (struct ipa_node_params *info, int i)
arguments. It can be accessed by the IPA_EDGE_REF macro. */ arguments. It can be accessed by the IPA_EDGE_REF macro. */
typedef struct GTY(()) ipa_edge_args typedef struct GTY(()) ipa_edge_args
{ {
/* Number of actual arguments in this callsite. When set to 0, /* Vector of the callsite's jump function of each parameter. */
this callsite's parameters would not be analyzed by the different VEC (ipa_jump_func_t, gc) *jump_functions;
stages of IPA CP. */
int argument_count;
/* Array of the callsite's jump function of each parameter. */
struct ipa_jump_func GTY ((length ("%h.argument_count"))) *jump_functions;
} ipa_edge_args_t; } ipa_edge_args_t;
/* ipa_edge_args access functions. Please use these to access fields that /* ipa_edge_args access functions. Please use these to access fields that
are or will be shared among various passes. */ are or will be shared among various passes. */
/* Set the number of actual arguments. */
static inline void
ipa_set_cs_argument_count (struct ipa_edge_args *args, int count)
{
args->argument_count = count;
}
/* Return the number of actual arguments. */ /* Return the number of actual arguments. */
static inline int static inline int
ipa_get_cs_argument_count (struct ipa_edge_args *args) ipa_get_cs_argument_count (struct ipa_edge_args *args)
{ {
return args->argument_count; return VEC_length (ipa_jump_func_t, args->jump_functions);
} }
/* Returns a pointer to the jump function for the ith argument. Please note /* Returns a pointer to the jump function for the ith argument. Please note
...@@ -257,8 +248,7 @@ ipa_get_cs_argument_count (struct ipa_edge_args *args) ...@@ -257,8 +248,7 @@ ipa_get_cs_argument_count (struct ipa_edge_args *args)
static inline struct ipa_jump_func * static inline struct ipa_jump_func *
ipa_get_ith_jump_func (struct ipa_edge_args *args, int i) ipa_get_ith_jump_func (struct ipa_edge_args *args, int i)
{ {
gcc_assert (i >= 0 && i <= args->argument_count); return VEC_index (ipa_jump_func_t, args->jump_functions, i);
return &args->jump_functions[i];
} }
/* Vectors need to have typedefs of structures. */ /* Vectors need to have typedefs of structures. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment