Commit 1628b2fa by Martin Liska Committed by Martin Liska

Clean up value-prof.c a bit.

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.

From-SVN: r274844
parent 1783e319
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> 2019-08-22 Martin Sebor <msebor@redhat.com>
PR middle-end/91490 PR middle-end/91490
......
...@@ -160,31 +160,31 @@ instrument_values (histogram_values values) ...@@ -160,31 +160,31 @@ instrument_values (histogram_values values)
switch (hist->type) switch (hist->type)
{ {
case HIST_TYPE_INTERVAL: case HIST_TYPE_INTERVAL:
gimple_gen_interval_profiler (hist, t, 0); gimple_gen_interval_profiler (hist, t);
break; break;
case HIST_TYPE_POW2: case HIST_TYPE_POW2:
gimple_gen_pow2_profiler (hist, t, 0); gimple_gen_pow2_profiler (hist, t);
break; break;
case HIST_TYPE_TOPN_VALUES: case HIST_TYPE_TOPN_VALUES:
gimple_gen_topn_values_profiler (hist, t, 0); gimple_gen_topn_values_profiler (hist, t);
break; break;
case HIST_TYPE_INDIR_CALL: case HIST_TYPE_INDIR_CALL:
gimple_gen_ic_profiler (hist, t, 0); gimple_gen_ic_profiler (hist, t);
break; break;
case HIST_TYPE_AVERAGE: case HIST_TYPE_AVERAGE:
gimple_gen_average_profiler (hist, t, 0); gimple_gen_average_profiler (hist, t);
break; break;
case HIST_TYPE_IOR: case HIST_TYPE_IOR:
gimple_gen_ior_profiler (hist, t, 0); gimple_gen_ior_profiler (hist, t);
break; break;
case HIST_TYPE_TIME_PROFILE: case HIST_TYPE_TIME_PROFILE:
gimple_gen_time_profiler (t, 0); gimple_gen_time_profiler (t);
break; break;
default: default:
......
...@@ -293,11 +293,11 @@ prepare_instrumented_value (gimple_stmt_iterator *gsi, histogram_value value) ...@@ -293,11 +293,11 @@ prepare_instrumented_value (gimple_stmt_iterator *gsi, histogram_value value)
tag of the section for counters, BASE is offset of the counter position. */ tag of the section for counters, BASE is offset of the counter position. */
void 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 = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (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; gcall *call;
tree val; tree val;
tree start = build_int_cst_type (integer_type_node, tree start = build_int_cst_type (integer_type_node,
...@@ -316,14 +316,14 @@ gimple_gen_interval_profiler (histogram_value value, unsigned tag, unsigned base ...@@ -316,14 +316,14 @@ gimple_gen_interval_profiler (histogram_value value, unsigned tag, unsigned base
/* Output instructions as GIMPLE trees to increment the power of two histogram /* 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 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 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 = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (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; gcall *call;
tree val; tree val;
...@@ -336,15 +336,14 @@ gimple_gen_pow2_profiler (histogram_value value, unsigned tag, unsigned base) ...@@ -336,15 +336,14 @@ gimple_gen_pow2_profiler (histogram_value value, unsigned tag, unsigned base)
/* Output instructions as GIMPLE trees for code to find the most N common /* 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 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 void
gimple_gen_topn_values_profiler (histogram_value value, unsigned tag, gimple_gen_topn_values_profiler (histogram_value value, unsigned tag)
unsigned base)
{ {
gimple *stmt = value->hvalue.stmt; gimple *stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (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; gcall *call;
tree val; tree val;
...@@ -359,17 +358,16 @@ gimple_gen_topn_values_profiler (histogram_value value, unsigned tag, ...@@ -359,17 +358,16 @@ gimple_gen_topn_values_profiler (histogram_value value, unsigned tag,
/* Output instructions as GIMPLE trees for code to find the most /* Output instructions as GIMPLE trees for code to find the most
common called function in indirect call. common called function in indirect call.
VALUE is the call expression whose indirect callee is profiled. VALUE is the call expression whose indirect callee is profiled.
TAG is the tag of the section for counters, BASE is offset of the TAG is the tag of the section for counters. */
counter position. */
void void
gimple_gen_ic_profiler (histogram_value value, unsigned tag, unsigned base) gimple_gen_ic_profiler (histogram_value value, unsigned tag)
{ {
tree tmp1; tree tmp1;
gassign *stmt1, *stmt2, *stmt3; gassign *stmt1, *stmt2, *stmt3;
gimple *stmt = value->hvalue.stmt; gimple *stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (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, ref_ptr = force_gimple_operand_gsi (&gsi, ref_ptr,
true, NULL_TREE, true, GSI_SAME_STMT); true, NULL_TREE, true, GSI_SAME_STMT);
...@@ -485,7 +483,7 @@ gimple_gen_ic_func_profiler (void) ...@@ -485,7 +483,7 @@ gimple_gen_ic_func_profiler (void)
counter position and GSI is the iterator we place the counter. */ counter position and GSI is the iterator we place the counter. */
void void
gimple_gen_time_profiler (unsigned tag, unsigned base) gimple_gen_time_profiler (unsigned tag)
{ {
tree type = get_gcov_type (); tree type = get_gcov_type ();
basic_block entry = ENTRY_BLOCK_PTR_FOR_FN (cfun); basic_block entry = ENTRY_BLOCK_PTR_FOR_FN (cfun);
...@@ -504,7 +502,7 @@ gimple_gen_time_profiler (unsigned tag, unsigned base) ...@@ -504,7 +502,7 @@ gimple_gen_time_profiler (unsigned tag, unsigned base)
e->probability = true_edge->probability.invert (); e->probability = true_edge->probability.invert ();
gimple_stmt_iterator gsi = gsi_start_bb (cond_bb); 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, tree ref = force_gimple_operand_gsi (&gsi, original_ref, true, NULL_TREE,
true, GSI_SAME_STMT); true, GSI_SAME_STMT);
tree one = build_int_cst (type, 1); tree one = build_int_cst (type, 1);
...@@ -564,11 +562,11 @@ gimple_gen_time_profiler (unsigned tag, unsigned base) ...@@ -564,11 +562,11 @@ gimple_gen_time_profiler (unsigned tag, unsigned base)
tag of the section for counters, BASE is offset of the counter position. */ tag of the section for counters, BASE is offset of the counter position. */
void 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 = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (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; gcall *call;
tree val; tree val;
...@@ -585,11 +583,11 @@ gimple_gen_average_profiler (histogram_value value, unsigned tag, unsigned base) ...@@ -585,11 +583,11 @@ gimple_gen_average_profiler (histogram_value value, unsigned tag, unsigned base)
tag of the section for counters, BASE is offset of the counter position. */ tag of the section for counters, BASE is offset of the counter position. */
void 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 = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (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; gcall *call;
tree val; tree val;
......
...@@ -300,7 +300,7 @@ dump_histogram_value (FILE *dump_file, histogram_value hist) ...@@ -300,7 +300,7 @@ dump_histogram_value (FILE *dump_file, histogram_value hist)
fprintf (dump_file, "Time profile time:%" PRId64 ".\n", fprintf (dump_file, "Time profile time:%" PRId64 ".\n",
(int64_t) hist->hvalue.counters[0]); (int64_t) hist->hvalue.counters[0]);
break; break;
case HIST_TYPE_MAX: default:
gcc_unreachable (); gcc_unreachable ();
} }
} }
...@@ -360,7 +360,7 @@ stream_in_histogram_value (class lto_input_block *ib, gimple *stmt) ...@@ -360,7 +360,7 @@ stream_in_histogram_value (class lto_input_block *ib, gimple *stmt)
bp = streamer_read_bitpack (ib); bp = streamer_read_bitpack (ib);
type = bp_unpack_enum (&bp, hist_type, HIST_TYPE_MAX); type = bp_unpack_enum (&bp, hist_type, HIST_TYPE_MAX);
next = bp_unpack_value (&bp, 1); 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) switch (type)
{ {
case HIST_TYPE_INTERVAL: case HIST_TYPE_INTERVAL:
...@@ -384,7 +384,7 @@ stream_in_histogram_value (class lto_input_block *ib, gimple *stmt) ...@@ -384,7 +384,7 @@ stream_in_histogram_value (class lto_input_block *ib, gimple *stmt)
ncounters = 1; ncounters = 1;
break; break;
case HIST_TYPE_MAX: default:
gcc_unreachable (); gcc_unreachable ();
} }
new_val->hvalue.counters = XNEWVAR (gcov_type, sizeof (*new_val->hvalue.counters) * ncounters); new_val->hvalue.counters = XNEWVAR (gcov_type, sizeof (*new_val->hvalue.counters) * ncounters);
...@@ -429,7 +429,7 @@ gimple_duplicate_stmt_histograms (struct function *fun, gimple *stmt, ...@@ -429,7 +429,7 @@ gimple_duplicate_stmt_histograms (struct function *fun, gimple *stmt,
histogram_value val; histogram_value val;
for (val = gimple_histogram_value (ofun, ostmt); val != NULL; val = val->hvalue.next) 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)); memcpy (new_val, val, sizeof (*val));
new_val->hvalue.stmt = stmt; new_val->hvalue.stmt = stmt;
new_val->hvalue.counters = XNEWVAR (gcov_type, sizeof (*new_val->hvalue.counters) * new_val->n_counters); new_val->hvalue.counters = XNEWVAR (gcov_type, sizeof (*new_val->hvalue.counters) * new_val->n_counters);
...@@ -1791,14 +1791,12 @@ gimple_divmod_values_to_profile (gimple *stmt, histogram_values *values) ...@@ -1791,14 +1791,12 @@ gimple_divmod_values_to_profile (gimple *stmt, histogram_values *values)
divisor = gimple_assign_rhs2 (stmt); divisor = gimple_assign_rhs2 (stmt);
op0 = gimple_assign_rhs1 (stmt); op0 = gimple_assign_rhs1 (stmt);
values->reserve (3);
if (TREE_CODE (divisor) == SSA_NAME) if (TREE_CODE (divisor) == SSA_NAME)
/* Check for the case where the divisor is the same value most /* Check for the case where the divisor is the same value most
of the time. */ of the time. */
values->quick_push (gimple_alloc_histogram_value (cfun, values->safe_push (gimple_alloc_histogram_value (cfun,
HIST_TYPE_TOPN_VALUES, HIST_TYPE_TOPN_VALUES,
stmt, divisor)); stmt, divisor));
/* For mod, check whether it is not often a noop (or replaceable by /* For mod, check whether it is not often a noop (or replaceable by
a few subtractions). */ a few subtractions). */
...@@ -1808,16 +1806,15 @@ gimple_divmod_values_to_profile (gimple *stmt, histogram_values *values) ...@@ -1808,16 +1806,15 @@ gimple_divmod_values_to_profile (gimple *stmt, histogram_values *values)
{ {
tree val; tree val;
/* Check for a special case where the divisor is power of 2. */ /* Check for a special case where the divisor is power of 2. */
values->quick_push (gimple_alloc_histogram_value (cfun, values->safe_push (gimple_alloc_histogram_value (cfun,
HIST_TYPE_POW2, HIST_TYPE_POW2,
stmt, divisor)); stmt, divisor));
val = build2 (TRUNC_DIV_EXPR, type, op0, divisor); val = build2 (TRUNC_DIV_EXPR, type, op0, divisor);
hist = gimple_alloc_histogram_value (cfun, HIST_TYPE_INTERVAL, hist = gimple_alloc_histogram_value (cfun, HIST_TYPE_INTERVAL,
stmt, val); stmt, val);
hist->hdata.intvl.int_start = 0; hist->hdata.intvl.int_start = 0;
hist->hdata.intvl.steps = 2; hist->hdata.intvl.steps = 2;
values->quick_push (hist); values->safe_push (hist);
} }
return; return;
...@@ -1840,11 +1837,9 @@ gimple_indirect_call_to_profile (gimple *stmt, histogram_values *values) ...@@ -1840,11 +1837,9 @@ gimple_indirect_call_to_profile (gimple *stmt, histogram_values *values)
return; return;
callee = gimple_call_fn (stmt); callee = gimple_call_fn (stmt);
histogram_value v = gimple_alloc_histogram_value (cfun, HIST_TYPE_INDIR_CALL,
values->reserve (3); stmt, callee);
values->safe_push (v);
values->quick_push (gimple_alloc_histogram_value (cfun, HIST_TYPE_INDIR_CALL,
stmt, callee));
return; return;
} }
...@@ -1911,7 +1906,8 @@ gimple_find_values_to_profile (histogram_values *values) ...@@ -1911,7 +1906,8 @@ gimple_find_values_to_profile (histogram_values *values)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
gimple_values_to_profile (gsi_stmt (gsi), values); 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) FOR_EACH_VEC_ELT (*values, i, hist)
{ {
......
...@@ -73,7 +73,8 @@ extern void gimple_find_values_to_profile (histogram_values *); ...@@ -73,7 +73,8 @@ extern void gimple_find_values_to_profile (histogram_values *);
extern bool gimple_value_profile_transformations (void); extern bool gimple_value_profile_transformations (void);
histogram_value gimple_alloc_histogram_value (struct function *, enum hist_type, 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 (struct function *, gimple *);
histogram_value gimple_histogram_value_of_type (struct function *, gimple *, histogram_value gimple_histogram_value_of_type (struct function *, gimple *,
enum hist_type); enum hist_type);
...@@ -97,15 +98,14 @@ bool get_nth_most_common_value (gimple *stmt, const char *counter_type, ...@@ -97,15 +98,14 @@ bool get_nth_most_common_value (gimple *stmt, const char *counter_type,
/* In tree-profile.c. */ /* In tree-profile.c. */
extern void gimple_init_gcov_profiler (void); extern void gimple_init_gcov_profiler (void);
extern void gimple_gen_edge_profiler (int, edge); extern void gimple_gen_edge_profiler (int, edge);
extern void gimple_gen_interval_profiler (histogram_value, unsigned, unsigned); extern void gimple_gen_interval_profiler (histogram_value, unsigned);
extern void gimple_gen_pow2_profiler (histogram_value, unsigned, unsigned); extern void gimple_gen_pow2_profiler (histogram_value, unsigned);
extern void gimple_gen_topn_values_profiler (histogram_value, unsigned, extern void gimple_gen_topn_values_profiler (histogram_value, unsigned);
unsigned); extern void gimple_gen_ic_profiler (histogram_value, unsigned);
extern void gimple_gen_ic_profiler (histogram_value, unsigned, unsigned);
extern void gimple_gen_ic_func_profiler (void); extern void gimple_gen_ic_func_profiler (void);
extern void gimple_gen_time_profiler (unsigned, unsigned); extern void gimple_gen_time_profiler (unsigned);
extern void gimple_gen_average_profiler (histogram_value, unsigned, unsigned); extern void gimple_gen_average_profiler (histogram_value, unsigned);
extern void gimple_gen_ior_profiler (histogram_value, unsigned, unsigned); extern void gimple_gen_ior_profiler (histogram_value, unsigned);
extern void stream_out_histogram_value (struct output_block *, histogram_value); extern void stream_out_histogram_value (struct output_block *, histogram_value);
extern void stream_in_histogram_value (class lto_input_block *, gimple *); extern void stream_in_histogram_value (class lto_input_block *, gimple *);
extern struct cgraph_node* find_func_by_profile_id (int func_id); extern struct cgraph_node* find_func_by_profile_id (int func_id);
......
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