aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2020-06-25 11:20:52 +0200
committerMartin Liska <mliska@suse.cz>2020-06-25 11:27:12 +0200
commit88891c5ff0e3e20d3dd743c4eb6cc45399ee5c33 (patch)
treeb90351f275fb454261cfb91a278cfead392e4e48 /libgcc
parenta8d8caca0cbfde0317ca96bfea75a7f047152dad (diff)
downloadgcc-88891c5ff0e3e20d3dd743c4eb6cc45399ee5c33.zip
gcc-88891c5ff0e3e20d3dd743c4eb6cc45399ee5c33.tar.gz
gcc-88891c5ff0e3e20d3dd743c4eb6cc45399ee5c33.tar.bz2
gcov-tool: fix merge operation for summary
libgcc/ChangeLog: * libgcov-driver.c (merge_summary): Remove function as its name is misleading and doing something different. (dump_one_gcov): Add ATTRIBUTE_UNUSED for 2 args. Take read summary in gcov-tool. * libgcov-util.c (curr_object_summary): Remove. (read_gcda_file): Remove unused curr_object_summary. (gcov_merge): Merge summaries. * libgcov.h: Add summary argument for gcov_info struct.
Diffstat (limited to 'libgcc')
-rw-r--r--libgcc/libgcov-driver.c26
-rw-r--r--libgcc/libgcov-util.c11
-rw-r--r--libgcc/libgcov.h1
3 files changed, 18 insertions, 20 deletions
diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index cbfcae9..871b87b 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -442,19 +442,6 @@ write_one_data (const struct gcov_info *gi_ptr,
gcov_write_unsigned (0);
}
-/* Helper function for merging summary. */
-
-static void
-merge_summary (int run_counted, struct gcov_summary *summary,
- gcov_type run_max)
-{
- if (!run_counted)
- {
- summary->runs++;
- summary->sum_max += run_max;
- }
-}
-
/* Dump the coverage counts for one gcov_info object. We merge with existing
counts when possible, to avoid growing the .da files ad infinitum. We use
this program's checksum to make sure we only accumulate whole program
@@ -464,7 +451,8 @@ merge_summary (int run_counted, struct gcov_summary *summary,
static void
dump_one_gcov (struct gcov_info *gi_ptr, struct gcov_filename *gf,
- unsigned run_counted, gcov_type run_max)
+ unsigned run_counted ATTRIBUTE_UNUSED,
+ gcov_type run_max ATTRIBUTE_UNUSED)
{
struct gcov_summary summary = {};
int error;
@@ -492,7 +480,15 @@ dump_one_gcov (struct gcov_info *gi_ptr, struct gcov_filename *gf,
gcov_rewrite ();
- merge_summary (run_counted, &summary, run_max);
+#if !IN_GCOV_TOOL
+ if (!run_counted)
+ {
+ summary.runs++;
+ summary.sum_max += run_max;
+ }
+#else
+ summary = gi_ptr->summary;
+#endif
write_one_data (gi_ptr, &summary);
/* fall through */
diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c
index 224c190..09e34f0 100644
--- a/libgcc/libgcov-util.c
+++ b/libgcc/libgcov-util.c
@@ -80,8 +80,6 @@ static int k_ctrs_mask[GCOV_COUNTERS];
static struct gcov_ctr_info k_ctrs[GCOV_COUNTERS];
/* Number of kind of counters that have been seen. */
static int k_ctrs_types;
-/* The object summary being processed. */
-static struct gcov_summary *curr_object_summary;
/* Merge functions for counters. */
#define DEF_GCOV_COUNTER(COUNTER, NAME, FN_TYPE) __gcov_merge ## FN_TYPE,
@@ -225,8 +223,7 @@ tag_counters (unsigned tag, unsigned length)
static void
tag_summary (unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED)
{
- curr_object_summary = (gcov_summary *) xcalloc (sizeof (gcov_summary), 1);
- gcov_read_summary (curr_object_summary);
+ gcov_read_summary (&curr_gcov_info->summary);
}
/* This function is called at the end of reading a gcda file.
@@ -300,7 +297,6 @@ read_gcda_file (const char *filename)
obstack_init (&fn_info);
num_fn_info = 0;
curr_fn_info = 0;
- curr_object_summary = NULL;
{
size_t len = strlen (filename) + 1;
char *str_dup = (char*) xmalloc (len);
@@ -584,6 +580,11 @@ gcov_merge (struct gcov_info *info1, struct gcov_info *info2, int w)
int has_mismatch = 0;
gcc_assert (info2->n_functions == n_functions);
+
+ /* Merge summary. */
+ info1->summary.runs += info2->summary.runs;
+ info1->summary.sum_max += info2->summary.sum_max;
+
for (f_ix = 0; f_ix < n_functions; f_ix++)
{
unsigned t_ix;
diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h
index ffa9a69..81e1895 100644
--- a/libgcc/libgcov.h
+++ b/libgcc/libgcov.h
@@ -217,6 +217,7 @@ struct gcov_info
to function information */
#else
struct gcov_fn_info **functions;
+ struct gcov_summary summary;
#endif /* !IN_GCOV_TOOL */
};