aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2022-03-23 10:20:56 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-04-28 20:46:48 +0200
commit336ea18ad7f48d675fce8c97bf3b7a0ee3a5a450 (patch)
tree37913244bca7c139f0d7d0196150a578cdd1d6dd /libgcc
parent00c4405cd7f6a144d0a439e4d848d246920e6ff3 (diff)
downloadgcc-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 'libgcc')
-rw-r--r--libgcc/libgcov-util.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c
index ba7fb92..100f1b1 100644
--- a/libgcc/libgcov-util.c
+++ b/libgcc/libgcov-util.c
@@ -674,16 +674,16 @@ find_match_gcov_info (struct gcov_info **array, int size,
}
/* Merge the list of gcov_info objects from SRC_PROFILE to TGT_PROFILE.
- Return 0 on success: without mismatch.
- Reutrn 1 on error. */
+ Return the list of merged gcov_info objects. Return NULL if the list is
+ empty. */
-int
+struct gcov_info *
gcov_profile_merge (struct gcov_info *tgt_profile, struct gcov_info *src_profile,
int w1, int w2)
{
struct gcov_info *gi_ptr;
struct gcov_info **tgt_infos;
- struct gcov_info *tgt_tail;
+ struct gcov_info **tgt_tail;
struct gcov_info **in_src_not_tgt;
unsigned tgt_cnt = 0, src_cnt = 0;
unsigned unmatch_info_cnt = 0;
@@ -703,7 +703,10 @@ gcov_profile_merge (struct gcov_info *tgt_profile, struct gcov_info *src_profile
for (gi_ptr = tgt_profile, i = 0; gi_ptr; gi_ptr = gi_ptr->next, i++)
tgt_infos[i] = gi_ptr;
- tgt_tail = tgt_infos[tgt_cnt - 1];
+ if (tgt_cnt)
+ tgt_tail = &tgt_infos[tgt_cnt - 1]->next;
+ else
+ tgt_tail = &tgt_profile;
/* First pass on tgt_profile, we multiply w1 to all counters. */
if (w1 > 1)
@@ -732,14 +735,14 @@ gcov_profile_merge (struct gcov_info *tgt_profile, struct gcov_info *src_profile
gi_ptr = in_src_not_tgt[i];
gcov_merge (gi_ptr, gi_ptr, w2 - 1);
gi_ptr->next = NULL;
- tgt_tail->next = gi_ptr;
- tgt_tail = gi_ptr;
+ *tgt_tail = gi_ptr;
+ tgt_tail = &gi_ptr->next;
}
free (in_src_not_tgt);
free (tgt_infos);
- return 0;
+ return tgt_profile;
}
typedef gcov_type (*counter_op_fn) (gcov_type, void*, void*);