diff options
author | Martin Liska <mliska@suse.cz> | 2021-09-09 13:02:24 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2021-10-13 15:26:58 +0200 |
commit | 72e0c742bd01f8e7e6dcca64042b9ad7e75979de (patch) | |
tree | b902a8580178ec7ed6d4dc9416679a4d92f81e78 /libgcc | |
parent | 489c8f27296362dcfbc967aecef17ba7c5cab0f2 (diff) | |
download | gcc-72e0c742bd01f8e7e6dcca64042b9ad7e75979de.zip gcc-72e0c742bd01f8e7e6dcca64042b9ad7e75979de.tar.gz gcc-72e0c742bd01f8e7e6dcca64042b9ad7e75979de.tar.bz2 |
gcov: make profile merging smarter
Support merging of profiles that are built from a different .o files
but belong to the same source file. Moreover, a checksum is verified
during profile merging and so we can safely combine such profile.
PR gcov-profile/90364
gcc/ChangeLog:
* coverage.c (build_info): Emit checksum to the global variable.
(build_info_type): Add new field for checksum.
(coverage_obj_finish): Pass object_checksum.
(coverage_init): Use 0 as checksum for .gcno files.
* gcov-dump.c (dump_gcov_file): Dump also new checksum field.
* gcov.c (read_graph_file): Read also checksum.
* doc/invoke.texi: Document the behaviour change.
libgcc/ChangeLog:
* libgcov-driver.c (merge_one_data): Skip timestamp and verify
checksums.
(write_one_data): Write also checksum.
* libgcov-util.c (read_gcda_file): Read also checksum field.
* libgcov.h (struct gcov_info): Add new field.
Diffstat (limited to 'libgcc')
-rw-r--r-- | libgcc/libgcov-driver.c | 8 | ||||
-rw-r--r-- | libgcc/libgcov-util.c | 3 | ||||
-rw-r--r-- | libgcc/libgcov.h | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c index 087f71e..7aa97bb 100644 --- a/libgcc/libgcov-driver.c +++ b/libgcc/libgcov-driver.c @@ -260,12 +260,15 @@ merge_one_data (const char *filename, if (!gcov_version (gi_ptr, length, filename)) return -1; + /* Skip timestamp. */ + gcov_read_unsigned (); + length = gcov_read_unsigned (); - if (length != gi_ptr->stamp) + if (length != gi_ptr->checksum) { /* Read from a different compilation. Overwrite the file. */ gcov_error (GCOV_PROF_PREFIX "overwriting an existing profile data " - "with a different timestamp\n", filename); + "with a different checksum\n", filename); return 0; } @@ -495,6 +498,7 @@ write_one_data (const struct gcov_info *gi_ptr, dump_unsigned (GCOV_DATA_MAGIC, dump_fn, arg); dump_unsigned (GCOV_VERSION, dump_fn, arg); dump_unsigned (gi_ptr->stamp, dump_fn, arg); + dump_unsigned (gi_ptr->checksum, dump_fn, arg); #ifdef NEED_L_GCOV /* Generate whole program statistics. */ diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c index bc7416d..766ca35 100644 --- a/libgcc/libgcov-util.c +++ b/libgcc/libgcov-util.c @@ -310,6 +310,9 @@ read_gcda_file (const char *filename) /* Read stamp. */ obj_info->stamp = gcov_read_unsigned (); + /* Read checksum. */ + obj_info->checksum = gcov_read_unsigned (); + while (1) { gcov_position_t base; diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h index f6354a7..2a365c9 100644 --- a/libgcc/libgcov.h +++ b/libgcc/libgcov.h @@ -230,6 +230,7 @@ struct gcov_info struct gcov_info *next; /* link to next, used by libgcov */ gcov_unsigned_t stamp; /* uniquifying time stamp */ + gcov_unsigned_t checksum; /* unique object checksum */ const char *filename; /* output file name */ gcov_merge_fn merge[GCOV_COUNTERS]; /* merge functions (null for |