Commit f3181aa2 by Jan Hubicka Committed by Jan Hubicka

ipa-prop.c (ipa_propagate_indirect_call_infos): Remove obsolette WPA hack.

	* ipa-prop.c (ipa_propagate_indirect_call_infos): Remove obsolette
	WPA hack.
	* ipa-prop.h (ipa_get_param, ipa_is_param_used, ipa_param_cannot_devirtualize_p,
	ipa_param_types_vec_empty, ipa_get_ith_jump_func, ipa_get_lattice):
	Fortify array bounds.
	* ipa-inline-analysis.c (add_clause): Fix clause ordering.
	(and_predicates, or_predicates, predicates_equal_p, evaulate_predicate):
	Sanity check predicate length.
	(remap_predicate): Likewise; sanity check jump functions.
	(inline_read_section, inline_write_summary): Sanity check
	predicate length.

From-SVN: r172914
parent 739986ef
2011-04-24 Jan Hubicka <jh@suse.cz>
* ipa-prop.c (ipa_propagate_indirect_call_infos): Remove obsolette
WPA hack.
* ipa-prop.h (ipa_get_param, ipa_is_param_used, ipa_param_cannot_devirtualize_p,
ipa_param_types_vec_empty, ipa_get_ith_jump_func, ipa_get_lattice):
Fortify array bounds.
* ipa-inline-analysis.c (add_clause): Fix clause ordering.
(and_predicates, or_predicates, predicates_equal_p, evaulate_predicate):
Sanity check predicate length.
(remap_predicate): Likewise; sanity check jump functions.
(inline_read_section, inline_write_summary): Sanity check
predicate length.
2011-04-24 Paolo Carlini <paolo.carlini@oracle.com> 2011-04-24 Paolo Carlini <paolo.carlini@oracle.com>
PR other/48748 PR other/48748
......
...@@ -200,7 +200,7 @@ static inline void ...@@ -200,7 +200,7 @@ static inline void
add_clause (struct predicate *p, clause_t clause) add_clause (struct predicate *p, clause_t clause)
{ {
int i; int i;
int insert_here = 0; int insert_here = -1;
/* True clause. */ /* True clause. */
if (!clause) if (!clause)
return; return;
...@@ -211,7 +211,7 @@ add_clause (struct predicate *p, clause_t clause) ...@@ -211,7 +211,7 @@ add_clause (struct predicate *p, clause_t clause)
p->clause[0] = (1 << predicate_false_condition); p->clause[0] = (1 << predicate_false_condition);
p->clause[1] = 0; p->clause[1] = 0;
} }
for (i = 0; i < MAX_CLAUSES; i++) for (i = 0; i < MAX_CLAUSES - 1; i++)
{ {
if (p->clause[i] == clause) if (p->clause[i] == clause)
return; return;
...@@ -225,8 +225,11 @@ add_clause (struct predicate *p, clause_t clause) ...@@ -225,8 +225,11 @@ add_clause (struct predicate *p, clause_t clause)
return; return;
/* Keep clauses ordered by index, so equivalence testing is easy. */ /* Keep clauses ordered by index, so equivalence testing is easy. */
p->clause[i + 1] = 0; p->clause[i + 1] = 0;
for (;i > insert_here; i--) if (insert_here >= 0)
p->clause[i] = p->clause[i - 1]; for (;i > insert_here; i--)
p->clause[i] = p->clause[i - 1];
else
insert_here = i;
p->clause[insert_here] = clause; p->clause[insert_here] = clause;
} }
...@@ -239,7 +242,10 @@ and_predicates (struct predicate *p, struct predicate *p2) ...@@ -239,7 +242,10 @@ and_predicates (struct predicate *p, struct predicate *p2)
struct predicate out = *p; struct predicate out = *p;
int i; int i;
for (i = 0; p2->clause[i]; i++) for (i = 0; p2->clause[i]; i++)
add_clause (&out, p2->clause[i]); {
gcc_checking_assert (i < MAX_CLAUSES);
add_clause (&out, p2->clause[i]);
}
return out; return out;
} }
...@@ -264,7 +270,10 @@ or_predicates (struct predicate *p, struct predicate *p2) ...@@ -264,7 +270,10 @@ or_predicates (struct predicate *p, struct predicate *p2)
} }
for (i = 0; p->clause[i]; i++) for (i = 0; p->clause[i]; i++)
for (j = 0; p2->clause[j]; j++) for (j = 0; p2->clause[j]; j++)
add_clause (&out, p->clause[i] | p2->clause[j]); {
gcc_checking_assert (i < MAX_CLAUSES && j < MAX_CLAUSES);
add_clause (&out, p->clause[i] | p2->clause[j]);
}
return out; return out;
} }
...@@ -276,8 +285,11 @@ predicates_equal_p (struct predicate *p, struct predicate *p2) ...@@ -276,8 +285,11 @@ predicates_equal_p (struct predicate *p, struct predicate *p2)
{ {
int i; int i;
for (i = 0; p->clause[i]; i++) for (i = 0; p->clause[i]; i++)
if (p->clause[i] != p2->clause[i]) {
return false; gcc_checking_assert (i < MAX_CLAUSES);
if (p->clause[i] != p2->clause[i])
return false;
}
return !p2->clause[i]; return !p2->clause[i];
} }
...@@ -296,8 +308,11 @@ evaulate_predicate (struct predicate *p, clause_t possible_truths) ...@@ -296,8 +308,11 @@ evaulate_predicate (struct predicate *p, clause_t possible_truths)
/* See if we can find clause we can disprove. */ /* See if we can find clause we can disprove. */
for (i = 0; p->clause[i]; i++) for (i = 0; p->clause[i]; i++)
if (!(p->clause[i] & possible_truths)) {
return false; gcc_checking_assert (i < MAX_CLAUSES);
if (!(p->clause[i] & possible_truths))
return false;
}
return true; return true;
} }
...@@ -1166,6 +1181,8 @@ remap_predicate (struct inline_summary *info, struct inline_summary *callee_info ...@@ -1166,6 +1181,8 @@ remap_predicate (struct inline_summary *info, struct inline_summary *callee_info
int cond; int cond;
struct predicate clause_predicate = false_predicate (); struct predicate clause_predicate = false_predicate ();
gcc_assert (i < MAX_CLAUSES);
for (cond = 0; cond < NUM_CONDITIONS; cond ++) for (cond = 0; cond < NUM_CONDITIONS; cond ++)
/* Do we have condition we can't disprove? */ /* Do we have condition we can't disprove? */
if (clause & possible_truths & (1 << cond)) if (clause & possible_truths & (1 << cond))
...@@ -1240,6 +1257,7 @@ inline_merge_summary (struct cgraph_edge *edge) ...@@ -1240,6 +1257,7 @@ inline_merge_summary (struct cgraph_edge *edge)
&& jfunc->value.pass_through.operation == NOP_EXPR) && jfunc->value.pass_through.operation == NOP_EXPR)
map = jfunc->value.pass_through.formal_id; map = jfunc->value.pass_through.formal_id;
VEC_replace (int, operand_map, i, map); VEC_replace (int, operand_map, i, map);
gcc_assert (map < ipa_get_param_count (IPA_NODE_REF (to)));
} }
} }
for (i = 0; VEC_iterate (size_time_entry, callee_info->entry, i, e); i++) for (i = 0; VEC_iterate (size_time_entry, callee_info->entry, i, e); i++)
...@@ -1544,6 +1562,7 @@ inline_read_section (struct lto_file_decl_data *file_data, const char *data, ...@@ -1544,6 +1562,7 @@ inline_read_section (struct lto_file_decl_data *file_data, const char *data,
do do
{ {
clause = e.predicate.clause[k++] = lto_input_uleb128 (&ib); clause = e.predicate.clause[k++] = lto_input_uleb128 (&ib);
gcc_assert (k < MAX_CLAUSES);
} }
while (clause); while (clause);
...@@ -1658,8 +1677,11 @@ inline_write_summary (cgraph_node_set set, ...@@ -1658,8 +1677,11 @@ inline_write_summary (cgraph_node_set set,
lto_output_uleb128_stream (ob->main_stream, lto_output_uleb128_stream (ob->main_stream,
e->time); e->time);
for (j = 0; e->predicate.clause[j]; j++) for (j = 0; e->predicate.clause[j]; j++)
lto_output_uleb128_stream (ob->main_stream, {
e->predicate.clause[j]); gcc_assert (j < MAX_CLAUSES);
lto_output_uleb128_stream (ob->main_stream,
e->predicate.clause[j]);
}
lto_output_uleb128_stream (ob->main_stream, 0); lto_output_uleb128_stream (ob->main_stream, 0);
} }
} }
......
...@@ -1890,10 +1890,6 @@ bool ...@@ -1890,10 +1890,6 @@ bool
ipa_propagate_indirect_call_infos (struct cgraph_edge *cs, ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
VEC (cgraph_edge_p, heap) **new_edges) VEC (cgraph_edge_p, heap) **new_edges)
{ {
/* FIXME lto: We do not stream out indirect call information. */
if (flag_wpa)
return false;
/* Do nothing if the preparation phase has not been carried out yet /* Do nothing if the preparation phase has not been carried out yet
(i.e. during early inlining). */ (i.e. during early inlining). */
if (!ipa_node_params_vector) if (!ipa_node_params_vector)
......
...@@ -228,6 +228,7 @@ ipa_get_param_count (struct ipa_node_params *info) ...@@ -228,6 +228,7 @@ ipa_get_param_count (struct ipa_node_params *info)
static inline tree static inline tree
ipa_get_param (struct ipa_node_params *info, int i) ipa_get_param (struct ipa_node_params *info, int i)
{ {
gcc_assert (i >= 0 && i <= info->param_count);
return info->params[i].decl; return info->params[i].decl;
} }
...@@ -237,6 +238,7 @@ ipa_get_param (struct ipa_node_params *info, int i) ...@@ -237,6 +238,7 @@ ipa_get_param (struct ipa_node_params *info, int i)
static inline bool static inline bool
ipa_is_param_used (struct ipa_node_params *info, int i) ipa_is_param_used (struct ipa_node_params *info, int i)
{ {
gcc_assert (i >= 0 && i <= info->param_count);
return info->params[i].used; return info->params[i].used;
} }
...@@ -247,6 +249,7 @@ ipa_is_param_used (struct ipa_node_params *info, int i) ...@@ -247,6 +249,7 @@ ipa_is_param_used (struct ipa_node_params *info, int i)
static inline bool static inline bool
ipa_param_cannot_devirtualize_p (struct ipa_node_params *info, int i) ipa_param_cannot_devirtualize_p (struct ipa_node_params *info, int i)
{ {
gcc_assert (i >= 0 && i <= info->param_count);
return info->params[i].cannot_devirtualize; return info->params[i].cannot_devirtualize;
} }
...@@ -256,6 +259,7 @@ ipa_param_cannot_devirtualize_p (struct ipa_node_params *info, int i) ...@@ -256,6 +259,7 @@ ipa_param_cannot_devirtualize_p (struct ipa_node_params *info, int i)
static inline bool static inline bool
ipa_param_types_vec_empty (struct ipa_node_params *info, int i) ipa_param_types_vec_empty (struct ipa_node_params *info, int i)
{ {
gcc_assert (i >= 0 && i <= info->param_count);
return info->params[i].types == NULL; return info->params[i].types == NULL;
} }
...@@ -315,6 +319,7 @@ ipa_get_cs_argument_count (struct ipa_edge_args *args) ...@@ -315,6 +319,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 &args->jump_functions[i]; return &args->jump_functions[i];
} }
...@@ -528,6 +533,7 @@ tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, tree, ...@@ -528,6 +533,7 @@ tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, tree,
static inline struct ipcp_lattice * static inline struct ipcp_lattice *
ipa_get_lattice (struct ipa_node_params *info, int i) ipa_get_lattice (struct ipa_node_params *info, int i)
{ {
gcc_assert (i >= 0 && i <= info->param_count);
return &(info->params[i].ipcp_lattice); return &(info->params[i].ipcp_lattice);
} }
......
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