From fa2a18ee4ca39931554a23020d4919038a2b744b Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 31 Jan 2020 13:10:14 +0100 Subject: Make TOPN counter dynamically allocated. gcc/ChangeLog: * coverage.c (get_coverage_counts): Skip sanity check for TOP N counters as they have variable number of counters. * gcov-dump.c (main): Add new option -r. (print_usage): Likewise. (tag_counters): All new raw format. * gcov-io.h (struct gcov_kvp): New. (GCOV_TOPN_VALUES): Remove. (GCOV_TOPN_VALUES_COUNTERS): Likewise. (GCOV_TOPN_MEM_COUNTERS): New. (GCOV_TOPN_DISK_COUNTERS): Likewise. (GCOV_TOPN_MAXIMUM_TRACKED_VALUES): Likewise. * ipa-profile.c (ipa_profile_generate_summary): Use GCOV_TOPN_MAXIMUM_TRACKED_VALUES. (ipa_profile_write_edge_summary): Likewise. (ipa_profile_read_edge_summary): Likewise. (ipa_profile): Remove usage of GCOV_TOPN_VALUES. * profile.c (sort_hist_values): Sort variable number of counters. (compute_value_histograms): Special case for TOP N counters that have dynamic number of key-value pairs. * value-prof.c (dump_histogram_value): Dump variable number of key-value pairs. (stream_in_histogram_value): Stream in variable number of key-value pairs for TOP N counter. (get_nth_most_common_value): Deal with variable number of key-value pairs. (dump_ic_profile): Use GCOV_TOPN_MAXIMUM_TRACKED_VALUES for loop iteration. (gimple_find_values_to_profile): Set GCOV_TOPN_MEM_COUNTERS to n_counters. * doc/gcov-dump.texi: Document new -r option. libgcc/ChangeLog: * libgcov-driver.c (prune_topn_counter): Remove. (prune_counters): Likewise. (merge_one_data): Special case TOP N counters as they have variable length. (write_top_counters): New. (write_one_data): Special case TOP N. (dump_one_gcov): Do not prune TOP N counters. * libgcov-merge.c (merge_topn_values_set): Remove. (__gcov_merge_topn): Use gcov_topn_add_value. * libgcov-profiler.c (__gcov_topn_values_profiler_body): Likewise here. * libgcov.h (gcov_counter_add): New. (gcov_counter_set_if_null): Likewise. (gcov_topn_add_value): New. --- gcc/coverage.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcc/coverage.c') diff --git a/gcc/coverage.c b/gcc/coverage.c index 7d82e44..1dcda43 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -345,8 +345,11 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum, can do about it. */ return NULL; } - - if (entry->cfg_checksum != cfg_checksum || entry->n_counts != n_counts) + + if (entry->cfg_checksum != cfg_checksum + || (counter != GCOV_COUNTER_V_INDIR + && counter != GCOV_COUNTER_V_TOPN + && entry->n_counts != n_counts)) { static int warned = 0; bool warning_printed = false; -- cgit v1.1 From bcec22b6a70978bba4b41a6c465dba12cbb9b7bc Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 2 Jun 2020 10:11:07 +0200 Subject: Do not stream all zeros for gcda files. gcc/ChangeLog: PR gcov-profile/95348 * coverage.c (read_counts_file): Read only COUNTERS that are not all-zero. * gcov-dump.c (tag_function): Change signature from unsigned to signed integer. (tag_blocks): Likewise. (tag_arcs): Likewise. (tag_lines): Likewise. (tag_counters): Likewise. (tag_summary): Likewise. * gcov.c (read_count_file): Read all non-zero counters sensitively. libgcc/ChangeLog: PR gcov-profile/95348 * libgcov-driver.c (merge_one_data): Merge only profiles that are not of non-zero type. (write_one_data): Write counters only if there's one non-zero value. * libgcov-util.c (tag_function): Change signature from unsigned to int. (tag_blocks): Likewise. (tag_arcs): Likewise. (tag_counters): Likewise. (tag_summary): Likewise. (tag_lines): Read only if COUNTERS is non-zero. (read_gcda_file): Handle negative length for COUNTERS type. --- gcc/coverage.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gcc/coverage.c') diff --git a/gcc/coverage.c b/gcc/coverage.c index 1dcda43..f353c9c 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -245,7 +245,9 @@ read_counts_file (void) else if (GCOV_TAG_IS_COUNTER (tag) && fn_ident) { counts_entry **slot, *entry, elt; - unsigned n_counts = GCOV_TAG_COUNTER_NUM (length); + int read_length = (int)length; + length = read_length > 0 ? read_length : 0; + unsigned n_counts = GCOV_TAG_COUNTER_NUM (abs (read_length)); unsigned ix; elt.ident = fn_ident; @@ -274,8 +276,9 @@ read_counts_file (void) counts_hash = NULL; break; } - for (ix = 0; ix != n_counts; ix++) - entry->counts[ix] += gcov_read_counter (); + if (read_length > 0) + for (ix = 0; ix != n_counts; ix++) + entry->counts[ix] = gcov_read_counter (); } gcov_sync (offset, length); if ((is_error = gcov_is_error ())) -- cgit v1.1