diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2022-03-23 10:20:56 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2022-04-28 20:46:48 +0200 |
commit | 336ea18ad7f48d675fce8c97bf3b7a0ee3a5a450 (patch) | |
tree | 37913244bca7c139f0d7d0196150a578cdd1d6dd /gcc | |
parent | 00c4405cd7f6a144d0a439e4d848d246920e6ff3 (diff) | |
download | gcc-336ea18ad7f48d675fce8c97bf3b7a0ee3a5a450.zip gcc-336ea18ad7f48d675fce8c97bf3b7a0ee3a5a450.tar.gz gcc-336ea18ad7f48d675fce8c97bf3b7a0ee3a5a450.tar.bz2 |
gcov-tool: Allow merging of empty profile lists
The gcov_profile_merge() already had code to deal with profile information
which had no counterpart to merge with. For profile information from files
with no associated counterpart, the profile information is simply used as is
with the weighting transformation applied. Make sure that gcov_profile_merge()
works with an empty target profile list. Return the merged profile list.
gcc/
* gcov-tool.cc (gcov_profile_merge): Adjust return type.
(profile_merge): Allow merging of directories which contain no profile
files.
libgcc/
* libgcov-util.c (gcov_profile_merge): Return the list of merged
profiles. Accept empty target and source profile lists.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/gcov-tool.cc | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/gcc/gcov-tool.cc b/gcc/gcov-tool.cc index f4e42ae..2e4083a 100644 --- a/gcc/gcov-tool.cc +++ b/gcc/gcov-tool.cc @@ -40,7 +40,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif #include <getopt.h> -extern int gcov_profile_merge (struct gcov_info*, struct gcov_info*, int, int); +extern struct gcov_info *gcov_profile_merge (struct gcov_info*, + struct gcov_info*, int, int); extern int gcov_profile_overlap (struct gcov_info*, struct gcov_info*); extern int gcov_profile_normalize (struct gcov_info*, gcov_type); extern int gcov_profile_scale (struct gcov_info*, float, int, int); @@ -141,26 +142,18 @@ profile_merge (const char *d1, const char *d2, const char *out, int w1, int w2) { struct gcov_info *d1_profile; struct gcov_info *d2_profile; - int ret; + struct gcov_info *merged_profile; d1_profile = gcov_read_profile_dir (d1, 0); - if (!d1_profile) - return 1; - - if (d2) - { - d2_profile = gcov_read_profile_dir (d2, 0); - if (!d2_profile) - return 1; + d2_profile = gcov_read_profile_dir (d2, 0); - /* The actual merge: we overwrite to d1_profile. */ - ret = gcov_profile_merge (d1_profile, d2_profile, w1, w2); + /* The actual merge: we overwrite to d1_profile. */ + merged_profile = gcov_profile_merge (d1_profile, d2_profile, w1, w2); - if (ret) - return ret; - } - - gcov_output_files (out, d1_profile); + if (merged_profile) + gcov_output_files (out, merged_profile); + else if (verbose) + fnotice (stdout, "no profile files were merged\n"); return 0; } |