+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>
PR other/48748
add_clause (struct predicate *p, clause_t clause)
{
int i;
- int insert_here = 0;
+ int insert_here = -1;
/* True clause. */
if (!clause)
return;
p->clause[0] = (1 << predicate_false_condition);
p->clause[1] = 0;
}
- for (i = 0; i < MAX_CLAUSES; i++)
+ for (i = 0; i < MAX_CLAUSES - 1; i++)
{
if (p->clause[i] == clause)
return;
return;
/* Keep clauses ordered by index, so equivalence testing is easy. */
p->clause[i + 1] = 0;
- for (;i > insert_here; i--)
- p->clause[i] = p->clause[i - 1];
+ if (insert_here >= 0)
+ for (;i > insert_here; i--)
+ p->clause[i] = p->clause[i - 1];
+ else
+ insert_here = i;
p->clause[insert_here] = clause;
}
struct predicate out = *p;
int 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;
}
}
for (i = 0; p->clause[i]; i++)
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;
}
{
int 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];
}
/* See if we can find clause we can disprove. */
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;
}
int cond;
struct predicate clause_predicate = false_predicate ();
+ gcc_assert (i < MAX_CLAUSES);
+
for (cond = 0; cond < NUM_CONDITIONS; cond ++)
/* Do we have condition we can't disprove? */
if (clause & possible_truths & (1 << cond))
&& jfunc->value.pass_through.operation == NOP_EXPR)
map = jfunc->value.pass_through.formal_id;
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++)
do
{
clause = e.predicate.clause[k++] = lto_input_uleb128 (&ib);
+ gcc_assert (k < MAX_CLAUSES);
}
while (clause);
lto_output_uleb128_stream (ob->main_stream,
e->time);
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);
}
}
static inline tree
ipa_get_param (struct ipa_node_params *info, int i)
{
+ gcc_assert (i >= 0 && i <= info->param_count);
return info->params[i].decl;
}
static inline bool
ipa_is_param_used (struct ipa_node_params *info, int i)
{
+ gcc_assert (i >= 0 && i <= info->param_count);
return info->params[i].used;
}
static inline bool
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;
}
static inline bool
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;
}
static inline struct ipa_jump_func *
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];
}
static inline struct ipcp_lattice *
ipa_get_lattice (struct ipa_node_params *info, int i)
{
+ gcc_assert (i >= 0 && i <= info->param_count);
return &(info->params[i].ipcp_lattice);
}