+2019-08-23 Martin Liska <mliska@suse.cz>
+
+ * profile.c (instrument_values): Do not set
+ 0 as last argument.
+ * tree-profile.c (gimple_gen_interval_profiler): Remove
+ last argument.
+ (gimple_gen_pow2_profiler): Likewise.
+ (gimple_gen_topn_values_profiler): Likewise.
+ (gimple_gen_ic_profiler): Likewise.
+ (gimple_gen_time_profiler): Likewise.
+ (gimple_gen_average_profiler): Likewise.
+ (gimple_gen_ior_profiler): Likewise.
+ * value-prof.c (dump_histogram_value): Use default
+ in switch statement instead of HIST_TYPE_MAX.
+ (stream_in_histogram_value): Likewise.
+ (gimple_duplicate_stmt_histograms): Do not
+ use NULL for implicitly set arguments.
+ (gimple_divmod_values_to_profile): Do not use
+ reserve+quick_push.
+ (gimple_indirect_call_to_profile): Likewise.
+ (gimple_find_values_to_profile): Use implicit
+ function call arguments.
+ * value-prof.h (gimple_alloc_histogram_value):
+ Set default values.
+ (gimple_gen_interval_profiler): Remove last argument.
+ (gimple_gen_pow2_profiler): Likewise.
+ (gimple_gen_topn_values_profiler): Likewise.
+ (gimple_gen_ic_profiler): Likewise.
+ (gimple_gen_time_profiler): Likewise.
+ (gimple_gen_average_profiler): Likewise.
+ (gimple_gen_ior_profiler): Likewise.
+
2019-08-22 Martin Sebor <msebor@redhat.com>
PR middle-end/91490
switch (hist->type)
{
case HIST_TYPE_INTERVAL:
- gimple_gen_interval_profiler (hist, t, 0);
+ gimple_gen_interval_profiler (hist, t);
break;
case HIST_TYPE_POW2:
- gimple_gen_pow2_profiler (hist, t, 0);
+ gimple_gen_pow2_profiler (hist, t);
break;
case HIST_TYPE_TOPN_VALUES:
- gimple_gen_topn_values_profiler (hist, t, 0);
+ gimple_gen_topn_values_profiler (hist, t);
break;
case HIST_TYPE_INDIR_CALL:
- gimple_gen_ic_profiler (hist, t, 0);
+ gimple_gen_ic_profiler (hist, t);
break;
case HIST_TYPE_AVERAGE:
- gimple_gen_average_profiler (hist, t, 0);
+ gimple_gen_average_profiler (hist, t);
break;
case HIST_TYPE_IOR:
- gimple_gen_ior_profiler (hist, t, 0);
+ gimple_gen_ior_profiler (hist, t);
break;
case HIST_TYPE_TIME_PROFILE:
- gimple_gen_time_profiler (t, 0);
+ gimple_gen_time_profiler (t);
break;
default:
tag of the section for counters, BASE is offset of the counter position. */
void
-gimple_gen_interval_profiler (histogram_value value, unsigned tag, unsigned base)
+gimple_gen_interval_profiler (histogram_value value, unsigned tag)
{
gimple *stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
- tree ref = tree_coverage_counter_ref (tag, base), ref_ptr;
+ tree ref = tree_coverage_counter_ref (tag, 0), ref_ptr;
gcall *call;
tree val;
tree start = build_int_cst_type (integer_type_node,
/* Output instructions as GIMPLE trees to increment the power of two histogram
counter. VALUE is the expression whose value is profiled. TAG is the tag
- of the section for counters, BASE is offset of the counter position. */
+ of the section for counters. */
void
-gimple_gen_pow2_profiler (histogram_value value, unsigned tag, unsigned base)
+gimple_gen_pow2_profiler (histogram_value value, unsigned tag)
{
gimple *stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
- tree ref_ptr = tree_coverage_counter_addr (tag, base);
+ tree ref_ptr = tree_coverage_counter_addr (tag, 0);
gcall *call;
tree val;
/* Output instructions as GIMPLE trees for code to find the most N common
values. VALUE is the expression whose value is profiled. TAG is the tag
- of the section for counters, BASE is offset of the counter position. */
+ of the section for counters. */
void
-gimple_gen_topn_values_profiler (histogram_value value, unsigned tag,
- unsigned base)
+gimple_gen_topn_values_profiler (histogram_value value, unsigned tag)
{
gimple *stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
- tree ref_ptr = tree_coverage_counter_addr (tag, base);
+ tree ref_ptr = tree_coverage_counter_addr (tag, 0);
gcall *call;
tree val;
/* Output instructions as GIMPLE trees for code to find the most
common called function in indirect call.
VALUE is the call expression whose indirect callee is profiled.
- TAG is the tag of the section for counters, BASE is offset of the
- counter position. */
+ TAG is the tag of the section for counters. */
void
-gimple_gen_ic_profiler (histogram_value value, unsigned tag, unsigned base)
+gimple_gen_ic_profiler (histogram_value value, unsigned tag)
{
tree tmp1;
gassign *stmt1, *stmt2, *stmt3;
gimple *stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
- tree ref_ptr = tree_coverage_counter_addr (tag, base);
+ tree ref_ptr = tree_coverage_counter_addr (tag, 0);
ref_ptr = force_gimple_operand_gsi (&gsi, ref_ptr,
true, NULL_TREE, true, GSI_SAME_STMT);
counter position and GSI is the iterator we place the counter. */
void
-gimple_gen_time_profiler (unsigned tag, unsigned base)
+gimple_gen_time_profiler (unsigned tag)
{
tree type = get_gcov_type ();
basic_block entry = ENTRY_BLOCK_PTR_FOR_FN (cfun);
e->probability = true_edge->probability.invert ();
gimple_stmt_iterator gsi = gsi_start_bb (cond_bb);
- tree original_ref = tree_coverage_counter_ref (tag, base);
+ tree original_ref = tree_coverage_counter_ref (tag, 0);
tree ref = force_gimple_operand_gsi (&gsi, original_ref, true, NULL_TREE,
true, GSI_SAME_STMT);
tree one = build_int_cst (type, 1);
tag of the section for counters, BASE is offset of the counter position. */
void
-gimple_gen_average_profiler (histogram_value value, unsigned tag, unsigned base)
+gimple_gen_average_profiler (histogram_value value, unsigned tag)
{
gimple *stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
- tree ref_ptr = tree_coverage_counter_addr (tag, base);
+ tree ref_ptr = tree_coverage_counter_addr (tag, 0);
gcall *call;
tree val;
tag of the section for counters, BASE is offset of the counter position. */
void
-gimple_gen_ior_profiler (histogram_value value, unsigned tag, unsigned base)
+gimple_gen_ior_profiler (histogram_value value, unsigned tag)
{
gimple *stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
- tree ref_ptr = tree_coverage_counter_addr (tag, base);
+ tree ref_ptr = tree_coverage_counter_addr (tag, 0);
gcall *call;
tree val;
fprintf (dump_file, "Time profile time:%" PRId64 ".\n",
(int64_t) hist->hvalue.counters[0]);
break;
- case HIST_TYPE_MAX:
+ default:
gcc_unreachable ();
}
}
bp = streamer_read_bitpack (ib);
type = bp_unpack_enum (&bp, hist_type, HIST_TYPE_MAX);
next = bp_unpack_value (&bp, 1);
- new_val = gimple_alloc_histogram_value (cfun, type, stmt, NULL);
+ new_val = gimple_alloc_histogram_value (cfun, type, stmt);
switch (type)
{
case HIST_TYPE_INTERVAL:
ncounters = 1;
break;
- case HIST_TYPE_MAX:
+ default:
gcc_unreachable ();
}
new_val->hvalue.counters = XNEWVAR (gcov_type, sizeof (*new_val->hvalue.counters) * ncounters);
histogram_value val;
for (val = gimple_histogram_value (ofun, ostmt); val != NULL; val = val->hvalue.next)
{
- histogram_value new_val = gimple_alloc_histogram_value (fun, val->type, NULL, NULL);
+ histogram_value new_val = gimple_alloc_histogram_value (fun, val->type);
memcpy (new_val, val, sizeof (*val));
new_val->hvalue.stmt = stmt;
new_val->hvalue.counters = XNEWVAR (gcov_type, sizeof (*new_val->hvalue.counters) * new_val->n_counters);
divisor = gimple_assign_rhs2 (stmt);
op0 = gimple_assign_rhs1 (stmt);
- values->reserve (3);
-
if (TREE_CODE (divisor) == SSA_NAME)
/* Check for the case where the divisor is the same value most
of the time. */
- values->quick_push (gimple_alloc_histogram_value (cfun,
- HIST_TYPE_TOPN_VALUES,
- stmt, divisor));
+ values->safe_push (gimple_alloc_histogram_value (cfun,
+ HIST_TYPE_TOPN_VALUES,
+ stmt, divisor));
/* For mod, check whether it is not often a noop (or replaceable by
a few subtractions). */
{
tree val;
/* Check for a special case where the divisor is power of 2. */
- values->quick_push (gimple_alloc_histogram_value (cfun,
- HIST_TYPE_POW2,
- stmt, divisor));
-
+ values->safe_push (gimple_alloc_histogram_value (cfun,
+ HIST_TYPE_POW2,
+ stmt, divisor));
val = build2 (TRUNC_DIV_EXPR, type, op0, divisor);
hist = gimple_alloc_histogram_value (cfun, HIST_TYPE_INTERVAL,
stmt, val);
hist->hdata.intvl.int_start = 0;
hist->hdata.intvl.steps = 2;
- values->quick_push (hist);
+ values->safe_push (hist);
}
return;
return;
callee = gimple_call_fn (stmt);
-
- values->reserve (3);
-
- values->quick_push (gimple_alloc_histogram_value (cfun, HIST_TYPE_INDIR_CALL,
- stmt, callee));
+ histogram_value v = gimple_alloc_histogram_value (cfun, HIST_TYPE_INDIR_CALL,
+ stmt, callee);
+ values->safe_push (v);
return;
}
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
gimple_values_to_profile (gsi_stmt (gsi), values);
- values->safe_push (gimple_alloc_histogram_value (cfun, HIST_TYPE_TIME_PROFILE, 0, 0));
+ values->safe_push (gimple_alloc_histogram_value (cfun,
+ HIST_TYPE_TIME_PROFILE));
FOR_EACH_VEC_ELT (*values, i, hist)
{
extern bool gimple_value_profile_transformations (void);
histogram_value gimple_alloc_histogram_value (struct function *, enum hist_type,
- gimple *stmt, tree);
+ gimple *stmt = NULL,
+ tree value = NULL_TREE);
histogram_value gimple_histogram_value (struct function *, gimple *);
histogram_value gimple_histogram_value_of_type (struct function *, gimple *,
enum hist_type);
/* In tree-profile.c. */
extern void gimple_init_gcov_profiler (void);
extern void gimple_gen_edge_profiler (int, edge);
-extern void gimple_gen_interval_profiler (histogram_value, unsigned, unsigned);
-extern void gimple_gen_pow2_profiler (histogram_value, unsigned, unsigned);
-extern void gimple_gen_topn_values_profiler (histogram_value, unsigned,
- unsigned);
-extern void gimple_gen_ic_profiler (histogram_value, unsigned, unsigned);
+extern void gimple_gen_interval_profiler (histogram_value, unsigned);
+extern void gimple_gen_pow2_profiler (histogram_value, unsigned);
+extern void gimple_gen_topn_values_profiler (histogram_value, unsigned);
+extern void gimple_gen_ic_profiler (histogram_value, unsigned);
extern void gimple_gen_ic_func_profiler (void);
-extern void gimple_gen_time_profiler (unsigned, unsigned);
-extern void gimple_gen_average_profiler (histogram_value, unsigned, unsigned);
-extern void gimple_gen_ior_profiler (histogram_value, unsigned, unsigned);
+extern void gimple_gen_time_profiler (unsigned);
+extern void gimple_gen_average_profiler (histogram_value, unsigned);
+extern void gimple_gen_ior_profiler (histogram_value, unsigned);
extern void stream_out_histogram_value (struct output_block *, histogram_value);
extern void stream_in_histogram_value (class lto_input_block *, gimple *);
extern struct cgraph_node* find_func_by_profile_id (int func_id);