aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-cp.c
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2011-09-02 17:37:38 +0200
committerMartin Jambor <jamborm@gcc.gnu.org>2011-09-02 17:37:38 +0200
commitd7da5cc85cdef4207d10e8b79dce79ed12353fb9 (patch)
treec5080ee359d717b439069963cb722bd18f086222 /gcc/ipa-cp.c
parente9e1d143b5ea00f99191cd0e65c09ee972ebcedb (diff)
downloadgcc-d7da5cc85cdef4207d10e8b79dce79ed12353fb9.zip
gcc-d7da5cc85cdef4207d10e8b79dce79ed12353fb9.tar.gz
gcc-d7da5cc85cdef4207d10e8b79dce79ed12353fb9.tar.bz2
ipa-prop.h (ipa_node_params): Removed fields called_with_var_arguments and node_versionable.
2011-09-02 Martin Jambor <mjambor@suse.cz> * ipa-prop.h (ipa_node_params): Removed fields called_with_var_arguments and node_versionable. (ipa_set_called_with_variable_arg): Removed. (ipa_is_called_with_var_arguments): Likewise. * ipa-cp.c (ipa_get_lattice): Fixed index check in an assert. (determine_versionability): Do not check for type attributes and va builtins. Record versionability into inline summary. (initialize_node_lattices): Do not check ipa_is_called_with_var_arguments. (propagate_constants_accross_call): Likewise, ignore arguments we do not have PARM_DECLs for, set variable flag for parameters that were not passed a value. (create_specialized_node): Dump info that we cannot change signature. * ipa-prop.c (ipa_compute_jump_functions): Do not care about variable number of arguments. (ipa_make_edge_direct_to_target): Likewise. (ipa_update_after_lto_read): Likewise. (ipa_node_duplication_hook): Do not copy called_with_var_arguments flag. * tree-inline.c (copy_arguments_for_versioning): Copy PARM_DECLs if they were remapped. * testsuite/gcc.dg/ipa/ipcp-3.c: New test. From-SVN: r178485
Diffstat (limited to 'gcc/ipa-cp.c')
-rw-r--r--gcc/ipa-cp.c48
1 files changed, 17 insertions, 31 deletions
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 23eb1e2..e751899 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -221,7 +221,7 @@ static struct ipcp_value *values_topo;
static inline struct ipcp_lattice *
ipa_get_lattice (struct ipa_node_params *info, int i)
{
- gcc_assert (i >= 0 && i <= ipa_get_param_count (info));
+ gcc_assert (i >= 0 && i < ipa_get_param_count (info));
gcc_checking_assert (!info->ipcp_orig_node);
gcc_checking_assert (info->lattices);
return &(info->lattices[i]);
@@ -360,7 +360,6 @@ print_all_lattices (FILE * f, bool dump_sources, bool dump_benefits)
static void
determine_versionability (struct cgraph_node *node)
{
- struct cgraph_edge *edge;
const char *reason = NULL;
/* There are a number of generic reasons functions cannot be versioned. We
@@ -369,32 +368,15 @@ determine_versionability (struct cgraph_node *node)
if (node->alias || node->thunk.thunk_p)
reason = "alias or thunk";
else if (!inline_summary (node)->versionable)
- reason = "inliner claims it is so";
- else if (TYPE_ATTRIBUTES (TREE_TYPE (node->decl)))
- reason = "there are type attributes";
+ reason = "not a tree_versionable_function";
else if (cgraph_function_body_availability (node) <= AVAIL_OVERWRITABLE)
reason = "insufficient body availability";
- else
- /* Removing arguments doesn't work if the function takes varargs
- or use __builtin_apply_args.
- FIXME: handle this together with can_change_signature flag. */
- for (edge = node->callees; edge; edge = edge->next_callee)
- {
- tree t = edge->callee->decl;
- if (DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL
- && (DECL_FUNCTION_CODE (t) == BUILT_IN_APPLY_ARGS
- || DECL_FUNCTION_CODE (t) == BUILT_IN_VA_START))
- {
- reason = "prohibitive builtins called";
- break;
- };
- }
if (reason && dump_file && !node->alias && !node->thunk.thunk_p)
fprintf (dump_file, "Function %s/%i is not versionable, reason: %s.\n",
cgraph_node_name (node), node->uid, reason);
- IPA_NODE_REF (node)->node_versionable = (reason == NULL);
+ inline_summary (node)->versionable = (reason == NULL);
}
/* Return true if it is at all technically possible to create clones of a
@@ -403,7 +385,7 @@ determine_versionability (struct cgraph_node *node)
static bool
ipcp_versionable_function_p (struct cgraph_node *node)
{
- return IPA_NODE_REF (node)->node_versionable;
+ return inline_summary (node)->versionable;
}
/* Structure holding accumulated information about callers of a node. */
@@ -610,9 +592,7 @@ initialize_node_lattices (struct cgraph_node *node)
int i;
gcc_checking_assert (cgraph_function_with_gimple_body_p (node));
- if (ipa_is_called_with_var_arguments (info))
- disable = true;
- else if (!node->local.local)
+ if (!node->local.local)
{
/* When cloning is allowed, we can assume that externally visible
functions are not called. We will compensate this by cloning
@@ -1068,18 +1048,17 @@ propagate_constants_accross_call (struct cgraph_edge *cs)
struct cgraph_node *callee, *alias_or_thunk;
struct ipa_edge_args *args;
bool ret = false;
- int i, count;
+ int i, args_count, parms_count;
callee = cgraph_function_node (cs->callee, &availability);
if (!callee->analyzed)
return false;
gcc_checking_assert (cgraph_function_with_gimple_body_p (callee));
callee_info = IPA_NODE_REF (callee);
- if (ipa_is_called_with_var_arguments (callee_info))
- return false;
args = IPA_EDGE_REF (cs);
- count = ipa_get_cs_argument_count (args);
+ args_count = ipa_get_cs_argument_count (args);
+ parms_count = ipa_get_param_count (callee_info);
/* If this call goes through a thunk we must not propagate to the first (0th)
parameter. However, we might need to uncover a thunk from below a series
@@ -1095,7 +1074,7 @@ propagate_constants_accross_call (struct cgraph_edge *cs)
else
i = 0;
- for (; i < count; i++)
+ for (; (i < args_count) && (i < parms_count); i++)
{
struct ipa_jump_func *jump_func = ipa_get_ith_jump_func (args, i);
struct ipcp_lattice *dest_lat = ipa_get_lattice (callee_info, i);
@@ -1105,6 +1084,9 @@ propagate_constants_accross_call (struct cgraph_edge *cs)
else
ret |= propagate_accross_jump_function (cs, jump_func, dest_lat);
}
+ for (; i < parms_count; i++)
+ ret |= set_lattice_contains_variable (ipa_get_lattice (callee_info, i));
+
return ret;
}
@@ -2004,7 +1986,11 @@ create_specialized_node (struct cgraph_node *node,
}
}
else
- args_to_skip = NULL;
+ {
+ args_to_skip = NULL;
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, " cannot change function signature\n");
+ }
for (i = 0; i < count ; i++)
{