diff options
author | Martin Liska <mliska@suse.cz> | 2021-01-26 12:44:34 +0100 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2021-01-26 12:44:34 +0100 |
commit | d40b21eebc9d41c3cb9ccbdf6338968436550621 (patch) | |
tree | ecb1087a87f42743ddd7f59d704d9fea776edcac /libgcc/libgcov.h | |
parent | 80198c701a7fc09e736ccffe470ee5033ca59a69 (diff) | |
download | gcc-d40b21eebc9d41c3cb9ccbdf6338968436550621.zip gcc-d40b21eebc9d41c3cb9ccbdf6338968436550621.tar.gz gcc-d40b21eebc9d41c3cb9ccbdf6338968436550621.tar.bz2 |
libgcov: improve profile reproducibility
libgcc/ChangeLog:
PR gcov-profile/98739
* libgcov.h (gcov_topn_add_value): Do not train when
we have a merged profile with a negative number of total
value.
Diffstat (limited to 'libgcc/libgcov.h')
-rw-r--r-- | libgcc/libgcov.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h index df08e88..ddc6885 100644 --- a/libgcc/libgcov.h +++ b/libgcc/libgcov.h @@ -443,7 +443,13 @@ gcov_topn_add_value (gcov_type *counters, gcov_type value, gcov_type count, int use_atomic, int increment_total) { if (increment_total) - gcov_counter_add (&counters[0], 1, use_atomic); + { + /* In the multi-threaded mode, we can have an already merged profile + with a negative total value. In that case, we should bail out. */ + if (counters[0] < 0) + return 0; + gcov_counter_add (&counters[0], 1, use_atomic); + } struct gcov_kvp *prev_node = NULL; struct gcov_kvp *minimal_node = NULL; |