Commit 1b309ca5 by Martin Liska Committed by Martin Liska

Support N values in libgcov for single value counter type.

2019-07-03  Martin Liska  <mliska@suse.cz>

	* gcc.dg/tree-prof/val-prof-2.c: Update scanned pattern
	as we do now better.
2019-07-03  Martin Liska  <mliska@suse.cz>

	* libgcov-merge.c (merge_single_value_set): Support N values.
	* libgcov-profiler.c (__gcov_one_value_profiler_body): Likewise.

From-SVN: r273004
parent e157be91
2019-07-03 Martin Liska <mliska@suse.cz>
* gcc.dg/tree-prof/val-prof-2.c: Update scanned pattern
as we do now better.
2019-07-03 Eric Botcazou <ebotcazou@adacore.com> 2019-07-03 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/specs/debug1.ads: New test. * gnat.dg/specs/debug1.ads: New test.
......
...@@ -25,8 +25,5 @@ main () ...@@ -25,8 +25,5 @@ main ()
return 0; return 0;
} }
/* autofdo does not do value profiling so far */ /* autofdo does not do value profiling so far */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Transformation done: mod power of 2" "profile" } } */ /* { dg-final-use-not-autofdo { scan-ipa-dump "Transformation done: div/mod by constant 256" "profile" } } */
/* This is part of code checking that n is power of 2, so we are sure that the transformation
didn't get optimized out. */
/* { dg-final-use-not-autofdo { scan-tree-dump "n_\[0-9\]* \\+ (4294967295|0x0*ffffffff)" "optimized"} } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ /* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
2019-07-03 Martin Liska <mliska@suse.cz>
* libgcov-merge.c (merge_single_value_set): Support N values.
* libgcov-profiler.c (__gcov_one_value_profiler_body): Likewise.
2019-06-27 Ilia Diachkov <ilia.diachkov@optimitech.com> 2019-06-27 Ilia Diachkov <ilia.diachkov@optimitech.com>
* Makefile.in (USE_TM_CLONE_REGISTRY): New. * Makefile.in (USE_TM_CLONE_REGISTRY): New.
......
...@@ -89,49 +89,53 @@ __gcov_merge_time_profile (gcov_type *counters, unsigned n_counters) ...@@ -89,49 +89,53 @@ __gcov_merge_time_profile (gcov_type *counters, unsigned n_counters)
static void static void
merge_single_value_set (gcov_type *counters) merge_single_value_set (gcov_type *counters)
{ {
unsigned j;
gcov_type value, counter;
/* First value is number of total executions of the profiler. */ /* First value is number of total executions of the profiler. */
gcov_type all = gcov_get_counter_ignore_scaling (-1); gcov_type all = gcov_get_counter_ignore_scaling (-1);
counters[0] += all; counters[0] += all;
++counters; ++counters;
/* Read all part values. */
gcov_type read_counters[2 * GCOV_DISK_SINGLE_VALUES];
for (unsigned i = 0; i < GCOV_DISK_SINGLE_VALUES; i++) for (unsigned i = 0; i < GCOV_DISK_SINGLE_VALUES; i++)
{ {
value = gcov_get_counter_target (); read_counters[2 * i] = gcov_get_counter_target ();
counter = gcov_get_counter_ignore_scaling (-1); read_counters[2 * i + 1] = gcov_get_counter_ignore_scaling (-1);
}
if (counter == -1) if (read_counters[1] == -1)
{ {
counters[1] = -1; counters[1] = -1;
/* We can't return as we need to read all counters. */ return;
continue;
} }
else if (counter == 0 || counters[1] == -1)
for (unsigned i = 0; i < GCOV_DISK_SINGLE_VALUES; i++)
{ {
/* We can't return as we need to read all counters. */ if (read_counters[2 * i + 1] == 0)
continue; return;
}
unsigned j;
for (j = 0; j < GCOV_DISK_SINGLE_VALUES; j++) for (j = 0; j < GCOV_DISK_SINGLE_VALUES; j++)
{ {
if (counters[2 * j] == value) if (counters[2 * j] == read_counters[2 * i])
{ {
counters[2 * j + 1] += counter; counters[2 * j + 1] += read_counters[2 * i + 1];
break; break;
} }
else if (counters[2 * j + 1] == 0) else if (counters[2 * j + 1] == 0)
{ {
counters[2 * j] = value; counters[2 * j] += read_counters[2 * i];
counters[2 * j + 1] = counter; counters[2 * j + 1] += read_counters[2 * i + 1];
break; break;
} }
} }
/* We haven't found a free slot for the value, mark overflow. */ /* We haven't found a slot, bail out. */
if (j == GCOV_DISK_SINGLE_VALUES) if (j == GCOV_DISK_SINGLE_VALUES)
{
counters[1] = -1; counters[1] = -1;
return;
}
} }
} }
......
...@@ -118,20 +118,44 @@ static inline void ...@@ -118,20 +118,44 @@ static inline void
__gcov_one_value_profiler_body (gcov_type *counters, gcov_type value, __gcov_one_value_profiler_body (gcov_type *counters, gcov_type value,
int use_atomic) int use_atomic)
{ {
if (value == counters[1]) if (use_atomic)
counters[2]++; __atomic_fetch_add (&counters[0], 1, __ATOMIC_RELAXED);
else if (counters[2] == 0) else
counters[0]++;
++counters;
/* We have GCOV_DISK_SINGLE_VALUES as we can keep multiple values
next to each other. */
unsigned sindex = 0;
for (unsigned i = 0; i < GCOV_DISK_SINGLE_VALUES; i++)
{ {
counters[2] = 1; if (value == counters[2 * i])
counters[1] = value; {
} if (use_atomic)
__atomic_fetch_add (&counters[2 * i + 1], 1, __ATOMIC_RELAXED);
else else
counters[2]--; counters[2 * i + 1]++;
return;
}
else if (counters[2 * i + 1] == 0)
{
/* We found an empty slot. */
counters[2 * i] = value;
counters[2 * i + 1] = 1;
return;
}
if (counters[2 * i + 1] < counters[2 * sindex + 1])
sindex = i;
}
/* We haven't found an empty slot, then decrement the smallest. */
if (use_atomic) if (use_atomic)
__atomic_fetch_add (&counters[0], 1, __ATOMIC_RELAXED); __atomic_fetch_sub (&counters[2 * sindex + 1], 1, __ATOMIC_RELAXED);
else else
counters[0]++; counters[2 * sindex + 1]--;
} }
#ifdef L_gcov_one_value_profiler_v2 #ifdef L_gcov_one_value_profiler_v2
......
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