bool found = false;
int i;
predicate nonconst_pred;
- vec<size_time_entry, va_gc> *table = call
- ? call_size_time_table : size_time_table;
+ vec<size_time_entry> *table = call ? &call_size_time_table : &size_time_table;
if (exec_pred == false)
return;
/* We need to create initial empty unconditional clause, but otherwise
we don't need to account empty times and sizes. */
- if (!size && time == 0 && table)
+ if (!size && time == 0 && table->length ())
return;
/* Only for calls we are unaccounting what we previously recorded. */
gcc_checking_assert (time >= 0 || call);
- for (i = 0; vec_safe_iterate (table, i, &e); i++)
+ for (i = 0; table->iterate (i, &e); i++)
if (e->exec_predicate == exec_pred
&& e->nonconst_predicate == nonconst_pred)
{
new_entry.exec_predicate = exec_pred;
new_entry.nonconst_predicate = nonconst_pred;
if (call)
- vec_safe_push (call_size_time_table, new_entry);
+ call_size_time_table.safe_push (new_entry);
else
- vec_safe_push (size_time_table, new_entry);
+ size_time_table.safe_push (new_entry);
}
else
{
for (unsigned i = 0; i < len; i++)
edge_predicate_pool.remove ((*loop_strides)[i].predicate);
vec_free (conds);
- vec_free (size_time_table);
- vec_free (call_size_time_table);
+ call_size_time_table.release ();
vec_free (loop_iterations);
vec_free (loop_strides);
builtin_constant_p_parms.release ();
void
ipa_fn_summary_t::duplicate (cgraph_node *src,
cgraph_node *dst,
- ipa_fn_summary *,
+ ipa_fn_summary *src_info,
ipa_fn_summary *info)
{
- new (info) ipa_fn_summary (*ipa_fn_summaries->get (src));
+ new (info) ipa_fn_summary (*src_info);
/* TODO: as an optimization, we may avoid copying conditions
that are known to be false or true. */
info->conds = vec_safe_copy (info->conds);
out that something was optimized out. */
if (ipa_node_params_sum && cinfo && cinfo->tree_map)
{
- vec<size_time_entry, va_gc> *entry = info->size_time_table;
/* Use SRC parm info since it may not be copied yet. */
class ipa_node_params *parms_info = IPA_NODE_REF (src);
ipa_auto_call_arg_values avals;
bool inlined_to_p = false;
struct cgraph_edge *edge, *next;
- info->size_time_table = 0;
+ info->size_time_table.release ();
avals.m_known_vals.safe_grow_cleared (count, true);
for (i = 0; i < count; i++)
{
to be false.
TODO: as on optimization, we can also eliminate conditions known
to be true. */
- for (i = 0; vec_safe_iterate (entry, i, &e); i++)
+ for (i = 0; src_info->size_time_table.iterate (i, &e); i++)
{
predicate new_exec_pred;
predicate new_nonconst_pred;
}
else
{
- info->size_time_table = vec_safe_copy (info->size_time_table);
- info->loop_iterations = vec_safe_copy (info->loop_iterations);
+ info->size_time_table = src_info->size_time_table.copy ();
+ info->loop_iterations = vec_safe_copy (src_info->loop_iterations);
info->loop_strides = vec_safe_copy (info->loop_strides);
info->builtin_constant_p_parms
fprintf (f, " estimated growth:%i\n", (int) s->growth);
if (s->scc_no)
fprintf (f, " In SCC: %i\n", (int) s->scc_no);
- for (i = 0; vec_safe_iterate (s->size_time_table, i, &e); i++)
+ for (i = 0; s->size_time_table.iterate (i, &e); i++)
{
fprintf (f, " size:%f, time:%f",
(double) e->size / ipa_fn_summary::size_scale,
}
p_seg = add_condition (summary, params_summary, index,
- param_type, &aggpos, GT_EXPR,
+ param_type, &aggpos, GT_EXPR,
max, param_ops);
}
}
memset(&fbi, 0, sizeof(fbi));
vec_free (info->conds);
info->conds = NULL;
- vec_free (info->size_time_table);
- info->size_time_table = NULL;
+ info->size_time_table.release ();
+ info->call_size_time_table.release ();
/* When optimizing and analyzing for IPA inliner, initialize loop optimizer
so we can produce proper inline hints.
if (use_table)
{
/* Build summary if it is absent. */
- if (!sum->call_size_time_table)
+ if (!sum->call_size_time_table.length ())
{
predicate true_pred = true;
sum->account_size_time (0, 0, true_pred, true_pred, true);
sreal old_time = time ? *time : 0;
if (min_size)
- *min_size += (*sum->call_size_time_table)[0].size;
+ *min_size += sum->call_size_time_table[0].size;
unsigned int i;
size_time_entry *e;
/* Walk the table and account sizes and times. */
- for (i = 0; vec_safe_iterate (sum->call_size_time_table, i, &e);
+ for (i = 0; sum->call_size_time_table.iterate (i, &e);
i++)
if (e->exec_predicate.evaluate (possible_truths))
{
if ((flag_checking || dump_file)
/* Do not try to sanity check when we know we lost some
precision. */
- && sum->call_size_time_table->length ()
+ && sum->call_size_time_table.length ()
< ipa_fn_summary::max_size_time_table_size)
{
estimate_calls_size_and_time_1 (node, &old_size, NULL, &old_time, NULL,
sreal nonspecialized_time = time;
- min_size += (*info->size_time_table)[0].size;
- for (i = 0; vec_safe_iterate (info->size_time_table, i, &e); i++)
+ min_size += info->size_time_table[0].size;
+ for (i = 0; info->size_time_table.iterate (i, &e); i++)
{
bool exec = e->exec_predicate.evaluate (m_nonspec_possible_truths);
gcc_checking_assert (time >= 0);
}
}
- gcc_checking_assert ((*info->size_time_table)[0].exec_predicate == true);
- gcc_checking_assert ((*info->size_time_table)[0].nonconst_predicate == true);
+ gcc_checking_assert (info->size_time_table[0].exec_predicate == true);
+ gcc_checking_assert (info->size_time_table[0].nonconst_predicate == true);
gcc_checking_assert (min_size >= 0);
gcc_checking_assert (size >= 0);
gcc_checking_assert (time >= 0);
add_builtin_constant_p_parm (info, operand_map[ip]);
}
sreal freq = edge->sreal_frequency ();
- for (i = 0; vec_safe_iterate (callee_info->size_time_table, i, &e); i++)
+ for (i = 0; callee_info->size_time_table.iterate (i, &e); i++)
{
predicate p;
p = e->exec_predicate.remap_after_inlining
info->estimated_stack_size = peak;
inline_update_callee_summaries (edge->callee, es->loop_depth);
- if (info->call_size_time_table)
+ if (info->call_size_time_table.length ())
{
int edge_size = 0;
sreal edge_time = 0;
size_info->size = 0;
info->time = 0;
- for (i = 0; vec_safe_iterate (info->size_time_table, i, &e); i++)
+ for (i = 0; info->size_time_table.iterate (i, &e); i++)
{
size_info->size += e->size;
info->time += e->time;
}
- info->min_size = (*info->size_time_table)[0].size;
+ info->min_size = info->size_time_table[0].size;
if (reset)
- vec_free (info->call_size_time_table);
+ info->call_size_time_table.release ();
if (node->callees || node->indirect_calls)
estimate_calls_size_and_time (node, &size_info->size, &info->min_size,
&info->time, NULL,
info->conds->quick_push (c);
}
count2 = streamer_read_uhwi (&ib);
- gcc_assert (!info || !info->size_time_table);
+ gcc_assert (!info || !info->size_time_table.length ());
if (info && count2)
- vec_safe_reserve_exact (info->size_time_table, count2);
+ info->size_time_table.reserve_exact (count2);
for (j = 0; j < count2; j++)
{
class size_time_entry e;
e.nonconst_predicate.stream_in (&ib);
if (info)
- info->size_time_table->quick_push (e);
+ info->size_time_table.quick_push (e);
}
count2 = streamer_read_uhwi (&ib);
}
}
}
- streamer_write_uhwi (ob, vec_safe_length (info->size_time_table));
- for (i = 0; vec_safe_iterate (info->size_time_table, i, &e); i++)
+ streamer_write_uhwi (ob, info->size_time_table.length ());
+ for (i = 0; info->size_time_table.iterate (i, &e); i++)
{
streamer_write_uhwi (ob, e->size);
e->time.stream_out (ob);
/* Representation of function body size and time depending on the call
context. We keep simple array of record, every containing of predicate
and time/size to account. */
-class GTY(()) size_time_entry
+class size_time_entry
{
public:
/* Predicate for code to be executed. */
the executed code paths will simplify. */
predicate nonconst_predicate;
int size;
- sreal GTY((skip)) time;
+ sreal time;
};
/* Summary about function and stack frame sizes. We keep this info
fp_expressions (false),
estimated_stack_size (false),
time (0), conds (NULL),
- size_time_table (NULL), call_size_time_table (NULL),
+ size_time_table (), call_size_time_table (vNULL),
loop_iterations (NULL), loop_strides (NULL),
builtin_constant_p_parms (vNULL),
growth (0), scc_no (0)
inlinable (s.inlinable), single_caller (s.single_caller),
fp_expressions (s.fp_expressions),
estimated_stack_size (s.estimated_stack_size),
- time (s.time), conds (s.conds), size_time_table (s.size_time_table),
- call_size_time_table (NULL),
+ time (s.time), conds (s.conds), size_time_table (),
+ call_size_time_table (vNULL),
loop_iterations (s.loop_iterations), loop_strides (s.loop_strides),
builtin_constant_p_parms (s.builtin_constant_p_parms),
growth (s.growth), scc_no (s.scc_no)
accounted in call_size_time_table. This is because calls
are often adjusted by IPA optimizations and thus this summary
is generated from call summary information when needed. */
- vec<size_time_entry, va_gc> *size_time_table;
- vec<size_time_entry, va_gc> *call_size_time_table;
+ auto_vec<size_time_entry> GTY((skip)) size_time_table;
+ /* Unlike size_time_table that is initialized for all summaries
+ call_size_time_table is allocated only for functions with
+ many calls. Use effecient vl_ptr storage. */
+ vec<size_time_entry, va_heap, vl_ptr> GTY((skip)) call_size_time_table;
/* Predicates on when some loops in the function can have known bounds. */
vec<ipa_freqcounting_predicate, va_gc> *loop_iterations;