aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-prof.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2020-02-18 14:28:22 +0100
committerMartin Liska <mliska@suse.cz>2020-02-18 14:28:22 +0100
commitea0b12523d0d9a9059b5173ce9653b92ddfb284f (patch)
tree76bb545094dd99e705bce5e82aa1456d7bcdd26e /gcc/value-prof.c
parent0b2b45a68f48817e2310b12db3e03e648d4d2005 (diff)
downloadgcc-ea0b12523d0d9a9059b5173ce9653b92ddfb284f.zip
gcc-ea0b12523d0d9a9059b5173ce9653b92ddfb284f.tar.gz
gcc-ea0b12523d0d9a9059b5173ce9653b92ddfb284f.tar.bz2
Introduce -fprofile-reproducibility and support it with TOP N.
PR ipa/92924 * common.opt: Add -fprofile-reproducibility. * doc/invoke.texi: Document it. * value-prof.c (dump_histogram_value): Document and support behavior for counters[0] being a negative value. (get_nth_most_common_value): Handle negative counters[0] in respect to flag_profile_reproducible. PR ipa/92924 * libgcov-merge.c (merge_topn_values_set): Record when a TOP N counter becomes invalid. When merging remove a smallest value if the space is needed.
Diffstat (limited to 'gcc/value-prof.c')
-rw-r--r--gcc/value-prof.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index f0456c8..5f940f4 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -265,8 +265,10 @@ dump_histogram_value (FILE *dump_file, histogram_value hist)
? "Top N value counter" : "Indirect call counter"));
if (hist->hvalue.counters)
{
- fprintf (dump_file, " all: %" PRId64 ", values: ",
- (int64_t) hist->hvalue.counters[0]);
+ fprintf (dump_file, " all: %" PRId64 "%s, values: ",
+ abs ((int64_t) hist->hvalue.counters[0]),
+ hist->hvalue.counters[0] < 0
+ ? " (values missing)": "");
for (unsigned i = 0; i < GCOV_TOPN_VALUES; i++)
{
fprintf (dump_file, "[%" PRId64 ":%" PRId64 "]",
@@ -719,26 +721,39 @@ gimple_divmod_fixed_value (gassign *stmt, tree value, profile_probability prob,
/* Return the n-th value count of TOPN_VALUE histogram. If
there's a value, return true and set VALUE and COUNT
- arguments. */
+ arguments.
+
+ Counters have the following meaning.
+
+ abs (counters[0]) is the number of executions
+ for i in 0 ... TOPN-1
+ counters[2 * i + 1] is target
+ abs (counters[2 * i + 2]) is corresponding hitrate counter.
+
+ Value of counters[0] negative when counter became
+ full during merging and some values are lost. */
bool
get_nth_most_common_value (gimple *stmt, const char *counter_type,
histogram_value hist, gcov_type *value,
gcov_type *count, gcov_type *all, unsigned n)
{
- if (hist->hvalue.counters[2] == -1)
- return false;
-
gcc_assert (n < GCOV_TOPN_VALUES);
*count = 0;
*value = 0;
- gcov_type read_all = hist->hvalue.counters[0];
+ gcov_type read_all = abs (hist->hvalue.counters[0]);
gcov_type v = hist->hvalue.counters[2 * n + 1];
gcov_type c = hist->hvalue.counters[2 * n + 2];
+ if (hist->hvalue.counters[0] < 0
+ && (flag_profile_reproducible == PROFILE_REPRODUCIBILITY_PARALLEL_RUNS
+ || (flag_profile_reproducible
+ == PROFILE_REPRODUCIBILITY_MULTITHREADED)))
+ return false;
+
/* Indirect calls can't be verified. */
if (stmt
&& check_counter (stmt, counter_type, &c, &read_all,