On 1/22/20 2:35 PM, Jan Hubicka wrote:
On 1/22/20 12:09 PM, Martin Liška wrote:
stats for indirect_call:
total: 9210
invalid: 600
tracked values:
0 values: 6280 times (68.19%)
1 values: 1856 times (20.15%)
2 values: 264 times (2.87%)
3 values: 157 times (1.70%)
4 values: 53 times (0.58%)
stats for topn:
total: 1513
invalid: 178
tracked values:
0 values: 1034 times (68.34%)
1 values: 176 times (11.63%)
2 values: 68 times (4.49%)
3 values: 39 times (2.58%)
4 values: 18 times (1.19%)
After the fix patch I get to:
== Stats for gcc ==
stats for indirect_call:
total: 9210
invalid: 518
tracked values:
0 values: 7746 times (84.10%)
1 values: 827 times (8.98%)
2 values: 53 times (0.58%)
3 values: 60 times (0.65%)
4 values: 6 times (0.07%)
Which seems to me a reasonable improvement.
Martin
I am not too sure - the odd thing is that number of 0 values hash grown
up from 6280 to 7746. (68->84%) Do you have any idea why?
So my bet is that before the patch we had a bogus code. We detected invalid
stated with hiving first counter value == -1. Which could be also reached
with decrement of all values (0 - 1 == -1).
Maybe we would be interested in usage of a huge negative number to reflect
invalid state?
Martin
Honza
diff --git a/gcc/gcov-io.h b/gcc/gcov-io.h
index d21a43c4c31..775264709b6 100644
--- a/gcc/gcov-io.h
+++ b/gcc/gcov-io.h
@@ -272,6 +272,9 @@ GCOV_COUNTERS
/* Total number of single value counters. */
#define GCOV_TOPN_VALUES_COUNTERS (2 * GCOV_TOPN_VALUES + 1)
+/* Constant used for an invalid TOPN counter. */
+#define GCOV_TOPN_INVALID ((gcov_type)0x8000000000000000LL)
+
/* Convert a counter index to a tag. */
#define GCOV_TAG_FOR_COUNTER(COUNT) \
(GCOV_TAG_COUNTER_BASE + ((gcov_unsigned_t)(COUNT) << 17))
diff --git a/gcc/profile.c b/gcc/profile.c
index 1a669b86467..0156a218b1e 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -769,8 +769,8 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
static void
sort_hist_values (histogram_value hist)
{
- /* counters[2] equal to -1 means that all counters are invalidated. */
- if (hist->hvalue.counters[2] == -1)
+ /* counters[2] equal to GCOV_TOPN_INVALID means that all counters are invalidated. */
+ if (hist->hvalue.counters[2] == GCOV_TOPN_INVALID)
return;
gcc_assert (hist->type == HIST_TYPE_TOPN_VALUES
@@ -869,7 +869,7 @@ compute_value_histograms (histogram_values values, unsigned cfg_checksum,
|| hist->type == HIST_TYPE_INDIR_CALL)
{
/* Each count value is multiplied by GCOV_TOPN_VALUES. */
- if (hist->hvalue.counters[2] != -1)
+ if (hist->hvalue.counters[2] != GCOV_TOPN_INVALID)
for (unsigned i = 0; i < GCOV_TOPN_VALUES; i++)
hist->hvalue.counters[2 * i + 2]
= RDIV (hist->hvalue.counters[2 * i + 2], GCOV_TOPN_VALUES);
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index b7c7d7eaea5..491225b9cff 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -723,7 +723,7 @@ 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)
+ if (hist->hvalue.counters[2] == GCOV_TOPN_INVALID)
return false;
gcc_assert (n < GCOV_TOPN_VALUES);
diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index cdb611de2a2..2ced903a06c 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -219,7 +219,7 @@ static struct gcov_fn_buffer *fn_buffer;
static void
prune_topn_counter (gcov_type *counters, gcov_type all)
{
- if (counters[1] == -1)
+ if (counters[1] == GCOV_TOPN_INVALID)
return;
for (unsigned i = 0; i < GCOV_TOPN_VALUES; i++)
diff --git a/libgcc/libgcov-merge.c b/libgcc/libgcov-merge.c
index b658aec46c6..6127e401278 100644
--- a/libgcc/libgcov-merge.c
+++ b/libgcc/libgcov-merge.c
@@ -103,9 +103,9 @@ merge_topn_values_set (gcov_type *counters)
read_counters[2 * i + 1] = gcov_get_counter_ignore_scaling (-1);
}
- if (read_counters[1] == -1)
+ if (read_counters[1] == GCOV_TOPN_INVALID)
{
- counters[1] = -1;
+ counters[1] = GCOV_TOPN_INVALID;
return;
}
@@ -133,7 +133,7 @@ merge_topn_values_set (gcov_type *counters)
/* We haven't found a slot, bail out. */
if (j == GCOV_TOPN_VALUES)
{
- counters[1] = -1;
+ counters[1] = GCOV_TOPN_INVALID;
return;
}
}