Commit 7f3577f5 by Martin Liska Committed by Martin Liska

Simplify gcov_histogram as it's used only for ARCS counters.

2018-06-05  Martin Liska  <mliska@suse.cz>

	* auto-profile.c (read_autofdo_file): Do not use
	gcov_ctr_summary struct.
	(afdo_callsite_hot_enough_for_early_inline): Likewise.
	* coverage.c (struct counts_entry): Likewise.
	(read_counts_file): Read just single summary entry.
	(get_coverage_counts): Use gcov_summary struct.
	* coverage.h (get_coverage_counts): Likewise.
	* gcov-dump.c (dump_working_sets): Likewise.
	(tag_summary): Dump just single summary.
	* gcov-io.c (gcov_write_summary): Write just histogram
	summary.
	(gcov_read_summary): Read just single summary.
	(compute_working_sets): Use gcov_summary struct.
	* gcov-io.h (GCOV_TAG_SUMMARY_LENGTH): Remove usage
	of GCOV_COUNTERS_SUMMABLE.
	(GCOV_COUNTERS_SUMMABLE): Remove.
	(GCOV_FIRST_VALUE_COUNTER): Replace with
	GCOV_COUNTER_V_INTERVAL.
	(struct gcov_ctr_summary): Remove.
	(struct gcov_summary): Directly use fields of former
	gcov_ctr_summary.
	(compute_working_sets): Use gcov_summary struct.
	* gcov.c (read_count_file): Do not use ctrs fields.
	* lto-cgraph.c (merge_profile_summaries): Use gcov_summary
	struct.
	* lto-streamer.h (struct GTY): Make profile_info gcov_summary
	struct.
	* profile.c: Likewise.
	* profile.h: Likewise.
2018-06-05  Martin Liska  <mliska@suse.cz>

	* libgcov-driver.c (gcov_compute_histogram): Remove usage
	of gcov_ctr_summary.
	(compute_summary): Do it just for a single summary.
	(merge_one_data): Likewise.
	(merge_summary): Simplify as we read just single summary.
	(dump_one_gcov): Pass proper argument.
	* libgcov-util.c (compute_one_gcov): Simplify as we have just
	single summary.
	(gcov_info_count_all_cold): Likewise.
	(calculate_overlap): Likewise.

From-SVN: r261189
parent 632b10e1
2018-06-05 Martin Liska <mliska@suse.cz>
* auto-profile.c (read_autofdo_file): Do not use
gcov_ctr_summary struct.
(afdo_callsite_hot_enough_for_early_inline): Likewise.
* coverage.c (struct counts_entry): Likewise.
(read_counts_file): Read just single summary entry.
(get_coverage_counts): Use gcov_summary struct.
* coverage.h (get_coverage_counts): Likewise.
* gcov-dump.c (dump_working_sets): Likewise.
(tag_summary): Dump just single summary.
* gcov-io.c (gcov_write_summary): Write just histogram
summary.
(gcov_read_summary): Read just single summary.
(compute_working_sets): Use gcov_summary struct.
* gcov-io.h (GCOV_TAG_SUMMARY_LENGTH): Remove usage
of GCOV_COUNTERS_SUMMABLE.
(GCOV_COUNTERS_SUMMABLE): Remove.
(GCOV_FIRST_VALUE_COUNTER): Replace with
GCOV_COUNTER_V_INTERVAL.
(struct gcov_ctr_summary): Remove.
(struct gcov_summary): Directly use fields of former
gcov_ctr_summary.
(compute_working_sets): Use gcov_summary struct.
* gcov.c (read_count_file): Do not use ctrs fields.
* lto-cgraph.c (merge_profile_summaries): Use gcov_summary
struct.
* lto-streamer.h (struct GTY): Make profile_info gcov_summary
struct.
* profile.c: Likewise.
* profile.h: Likewise.
2018-06-05 Martin Liska <mliska@suse.cz>
PR gcov-profile/84846
* gcov.c (output_lines): Print working directory only
in intermediate format.
......
......@@ -318,8 +318,8 @@ static string_table *afdo_string_table;
/* Store the AutoFDO source profile. */
static autofdo_source_profile *afdo_source_profile;
/* gcov_ctr_summary structure to store the profile_info. */
static struct gcov_ctr_summary *afdo_profile_info;
/* gcov_summary structure to store the profile_info. */
static gcov_summary *afdo_profile_info;
/* Helper functions. */
......@@ -1682,8 +1682,7 @@ read_autofdo_file (void)
if (auto_profile_file == NULL)
auto_profile_file = DEFAULT_AUTO_PROFILE_FILE;
autofdo::afdo_profile_info = (struct gcov_ctr_summary *)xcalloc (
1, sizeof (struct gcov_ctr_summary));
autofdo::afdo_profile_info = XNEW (gcov_summary);
autofdo::afdo_profile_info->runs = 1;
autofdo::afdo_profile_info->sum_max = 0;
autofdo::afdo_profile_info->sum_all = 0;
......@@ -1713,7 +1712,7 @@ afdo_callsite_hot_enough_for_early_inline (struct cgraph_edge *edge)
if (count > 0)
{
bool is_hot;
const struct gcov_ctr_summary *saved_profile_info = profile_info;
const gcov_summary *saved_profile_info = profile_info;
/* At early inline stage, profile_info is not set yet. We need to
temporarily set it to afdo_profile_info to calculate hotness. */
profile_info = autofdo::afdo_profile_info;
......
......@@ -73,7 +73,7 @@ struct counts_entry : pointer_hash <counts_entry>
unsigned lineno_checksum;
unsigned cfg_checksum;
gcov_type *counts;
struct gcov_ctr_summary summary;
gcov_summary summary;
/* hash_table support. */
static inline hashval_t hash (const counts_entry *);
......@@ -185,7 +185,7 @@ static void
read_counts_file (void)
{
gcov_unsigned_t fn_ident = 0;
struct gcov_summary summary;
gcov_summary summary;
unsigned new_summary = 1;
gcov_unsigned_t tag;
int is_error = 0;
......@@ -241,27 +241,21 @@ read_counts_file (void)
else if (tag == GCOV_TAG_PROGRAM_SUMMARY)
{
struct gcov_summary sum;
unsigned ix;
if (new_summary)
memset (&summary, 0, sizeof (summary));
gcov_read_summary (&sum);
for (ix = 0; ix != GCOV_COUNTERS_SUMMABLE; ix++)
{
summary.ctrs[ix].runs += sum.ctrs[ix].runs;
summary.ctrs[ix].sum_all += sum.ctrs[ix].sum_all;
if (summary.ctrs[ix].run_max < sum.ctrs[ix].run_max)
summary.ctrs[ix].run_max = sum.ctrs[ix].run_max;
summary.ctrs[ix].sum_max += sum.ctrs[ix].sum_max;
}
summary.runs += sum.runs;
summary.sum_all += sum.sum_all;
if (summary.run_max < sum.run_max)
summary.run_max = sum.run_max;
summary.sum_max += sum.sum_max;
if (new_summary)
memcpy (summary.ctrs[GCOV_COUNTER_ARCS].histogram,
sum.ctrs[GCOV_COUNTER_ARCS].histogram,
sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
memcpy (summary.histogram, sum.histogram,
sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
else
gcov_histogram_merge (summary.ctrs[GCOV_COUNTER_ARCS].histogram,
sum.ctrs[GCOV_COUNTER_ARCS].histogram);
gcov_histogram_merge (summary.histogram, sum.histogram);
new_summary = 0;
}
else if (GCOV_TAG_IS_COUNTER (tag) && fn_ident)
......@@ -282,8 +276,8 @@ read_counts_file (void)
entry->ctr = elt.ctr;
entry->lineno_checksum = lineno_checksum;
entry->cfg_checksum = cfg_checksum;
if (elt.ctr < GCOV_COUNTERS_SUMMABLE)
entry->summary = summary.ctrs[elt.ctr];
if (elt.ctr == GCOV_COUNTER_ARCS)
entry->summary = summary;
entry->summary.num = n_counts;
entry->counts = XCNEWVEC (gcov_type, n_counts);
}
......@@ -306,23 +300,16 @@ read_counts_file (void)
counts_hash = NULL;
break;
}
else if (elt.ctr >= GCOV_COUNTERS_SUMMABLE)
{
error ("cannot merge separate %s counters for function %u",
ctr_names[elt.ctr], fn_ident);
goto skip_merge;
}
else
{
entry->summary.runs += summary.ctrs[elt.ctr].runs;
entry->summary.sum_all += summary.ctrs[elt.ctr].sum_all;
if (entry->summary.run_max < summary.ctrs[elt.ctr].run_max)
entry->summary.run_max = summary.ctrs[elt.ctr].run_max;
entry->summary.sum_max += summary.ctrs[elt.ctr].sum_max;
entry->summary.runs += summary.runs;
entry->summary.sum_all += summary.sum_all;
if (entry->summary.run_max < summary.run_max)
entry->summary.run_max = summary.run_max;
entry->summary.sum_max += summary.sum_max;
}
for (ix = 0; ix != n_counts; ix++)
entry->counts[ix] += gcov_read_counter ();
skip_merge:;
}
gcov_sync (offset, length);
if ((is_error = gcov_is_error ()))
......@@ -345,7 +332,7 @@ read_counts_file (void)
gcov_type *
get_coverage_counts (unsigned counter, unsigned expected,
unsigned cfg_checksum, unsigned lineno_checksum,
const struct gcov_ctr_summary **summary)
const gcov_summary **summary)
{
counts_entry *entry, elt;
......
......@@ -54,7 +54,7 @@ extern gcov_type *get_coverage_counts (unsigned /*counter*/,
unsigned /*expected*/,
unsigned /*cfg_checksum*/,
unsigned /*lineno_checksum*/,
const struct gcov_ctr_summary **);
const gcov_summary **);
extern tree get_gcov_type (void);
extern bool coverage_node_map_initialized_p (void);
......
......@@ -39,7 +39,7 @@ static void tag_lines (const char *, unsigned, unsigned, unsigned);
static void tag_counters (const char *, unsigned, unsigned, unsigned);
static void tag_summary (const char *, unsigned, unsigned, unsigned);
static void dump_working_sets (const char *filename ATTRIBUTE_UNUSED,
const struct gcov_ctr_summary *summary,
const gcov_summary *summary,
unsigned depth);
extern int main (int, char **);
......@@ -467,52 +467,47 @@ tag_summary (const char *filename ATTRIBUTE_UNUSED,
unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED,
unsigned depth)
{
struct gcov_summary summary;
unsigned ix, h_ix;
gcov_summary summary;
unsigned h_ix;
gcov_bucket_type *histo_bucket;
gcov_read_summary (&summary);
printf (" checksum=0x%08x", summary.checksum);
for (ix = 0; ix != GCOV_COUNTERS_SUMMABLE; ix++)
printf ("\n");
print_prefix (filename, depth, 0);
printf (VALUE_PADDING_PREFIX "counts=%u, runs=%u",
summary.num, summary.runs);
printf (", sum_all=%" PRId64,
(int64_t)summary.sum_all);
printf (", run_max=%" PRId64,
(int64_t)summary.run_max);
printf (", sum_max=%" PRId64,
(int64_t)summary.sum_max);
printf ("\n");
print_prefix (filename, depth, 0);
printf (VALUE_PADDING_PREFIX "counter histogram:");
for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
{
histo_bucket = &summary.histogram[h_ix];
if (!histo_bucket->num_counters)
continue;
printf ("\n");
print_prefix (filename, depth, 0);
printf (VALUE_PADDING_PREFIX "counts=%u, runs=%u",
summary.ctrs[ix].num, summary.ctrs[ix].runs);
printf (", sum_all=%" PRId64,
(int64_t)summary.ctrs[ix].sum_all);
printf (", run_max=%" PRId64,
(int64_t)summary.ctrs[ix].run_max);
printf (", sum_max=%" PRId64,
(int64_t)summary.ctrs[ix].sum_max);
if (ix != GCOV_COUNTER_ARCS)
continue;
printf ("\n");
print_prefix (filename, depth, 0);
printf (VALUE_PADDING_PREFIX "counter histogram:");
for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
{
histo_bucket = &summary.ctrs[ix].histogram[h_ix];
if (!histo_bucket->num_counters)
continue;
printf ("\n");
print_prefix (filename, depth, 0);
printf (VALUE_PADDING_PREFIX VALUE_PREFIX "num counts=%u, "
"min counter=%" PRId64 ", cum_counter=%" PRId64,
h_ix, histo_bucket->num_counters,
(int64_t)histo_bucket->min_value,
(int64_t)histo_bucket->cum_value);
}
if (flag_dump_working_sets)
dump_working_sets (filename, &summary.ctrs[ix], depth);
printf (VALUE_PADDING_PREFIX VALUE_PREFIX "num counts=%u, "
"min counter=%" PRId64 ", cum_counter=%" PRId64,
h_ix, histo_bucket->num_counters,
(int64_t)histo_bucket->min_value,
(int64_t)histo_bucket->cum_value);
}
if (flag_dump_working_sets)
dump_working_sets (filename, &summary, depth);
}
static void
dump_working_sets (const char *filename ATTRIBUTE_UNUSED,
const struct gcov_ctr_summary *summary,
const gcov_summary *summary,
unsigned depth)
{
gcov_working_set_t gcov_working_sets[NUM_GCOV_WORKING_SETS];
......
......@@ -446,8 +446,7 @@ gcov_write_tag_length (gcov_unsigned_t tag, gcov_unsigned_t length)
GCOV_LINKAGE void
gcov_write_summary (gcov_unsigned_t tag, const struct gcov_summary *summary)
{
unsigned ix, h_ix, bv_ix, h_cnt = 0;
const struct gcov_ctr_summary *csum;
unsigned h_ix, bv_ix, h_cnt = 0;
unsigned histo_bitvector[GCOV_HISTOGRAM_BITVECTOR_SIZE];
/* Count number of non-zero histogram entries, and fill in a bit vector
......@@ -455,38 +454,29 @@ gcov_write_summary (gcov_unsigned_t tag, const struct gcov_summary *summary)
counters. */
for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
histo_bitvector[bv_ix] = 0;
csum = &summary->ctrs[GCOV_COUNTER_ARCS];
for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
if (csum->histogram[h_ix].num_counters)
if (summary->histogram[h_ix].num_counters)
{
histo_bitvector[h_ix / 32] |= 1 << (h_ix % 32);
h_cnt++;
}
gcov_write_tag_length (tag, GCOV_TAG_SUMMARY_LENGTH (h_cnt));
gcov_write_unsigned (summary->checksum);
for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
gcov_write_unsigned (summary->num);
gcov_write_unsigned (summary->runs);
gcov_write_counter (summary->sum_all);
gcov_write_counter (summary->run_max);
gcov_write_counter (summary->sum_max);
for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
gcov_write_unsigned (histo_bitvector[bv_ix]);
for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
{
gcov_write_unsigned (csum->num);
gcov_write_unsigned (csum->runs);
gcov_write_counter (csum->sum_all);
gcov_write_counter (csum->run_max);
gcov_write_counter (csum->sum_max);
if (ix != GCOV_COUNTER_ARCS)
{
for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
gcov_write_unsigned (0);
continue;
}
for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
gcov_write_unsigned (histo_bitvector[bv_ix]);
for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
{
if (!csum->histogram[h_ix].num_counters)
continue;
gcov_write_unsigned (csum->histogram[h_ix].num_counters);
gcov_write_counter (csum->histogram[h_ix].min_value);
gcov_write_counter (csum->histogram[h_ix].cum_value);
}
if (!summary->histogram[h_ix].num_counters)
continue;
gcov_write_unsigned (summary->histogram[h_ix].num_counters);
gcov_write_counter (summary->histogram[h_ix].min_value);
gcov_write_counter (summary->histogram[h_ix].cum_value);
}
}
#endif /* IN_LIBGCOV */
......@@ -598,68 +588,64 @@ gcov_read_string (void)
GCOV_LINKAGE void
gcov_read_summary (struct gcov_summary *summary)
{
unsigned ix, h_ix, bv_ix, h_cnt = 0;
struct gcov_ctr_summary *csum;
unsigned h_ix, bv_ix, h_cnt = 0;
unsigned histo_bitvector[GCOV_HISTOGRAM_BITVECTOR_SIZE];
unsigned cur_bitvector;
summary->checksum = gcov_read_unsigned ();
for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
summary->num = gcov_read_unsigned ();
summary->runs = gcov_read_unsigned ();
summary->sum_all = gcov_read_counter ();
summary->run_max = gcov_read_counter ();
summary->sum_max = gcov_read_counter ();
memset (summary->histogram, 0,
sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
{
csum->num = gcov_read_unsigned ();
csum->runs = gcov_read_unsigned ();
csum->sum_all = gcov_read_counter ();
csum->run_max = gcov_read_counter ();
csum->sum_max = gcov_read_counter ();
memset (csum->histogram, 0,
sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
{
histo_bitvector[bv_ix] = gcov_read_unsigned ();
histo_bitvector[bv_ix] = gcov_read_unsigned ();
#if IN_LIBGCOV
/* When building libgcov we don't include system.h, which includes
hwint.h (where popcount_hwi is declared). However, libgcov.a
is built by the bootstrapped compiler and therefore the builtins
are always available. */
h_cnt += __builtin_popcount (histo_bitvector[bv_ix]);
/* When building libgcov we don't include system.h, which includes
hwint.h (where popcount_hwi is declared). However, libgcov.a
is built by the bootstrapped compiler and therefore the builtins
are always available. */
h_cnt += __builtin_popcount (histo_bitvector[bv_ix]);
#else
h_cnt += popcount_hwi (histo_bitvector[bv_ix]);
h_cnt += popcount_hwi (histo_bitvector[bv_ix]);
#endif
}
bv_ix = 0;
h_ix = 0;
cur_bitvector = 0;
while (h_cnt--)
{
/* Find the index corresponding to the next entry we will read in.
First find the next non-zero bitvector and re-initialize
the histogram index accordingly, then right shift and increment
the index until we find a set bit. */
while (!cur_bitvector)
{
h_ix = bv_ix * 32;
if (bv_ix >= GCOV_HISTOGRAM_BITVECTOR_SIZE)
gcov_error ("corrupted profile info: summary histogram "
"bitvector is corrupt");
cur_bitvector = histo_bitvector[bv_ix++];
}
while (!(cur_bitvector & 0x1))
{
h_ix++;
cur_bitvector >>= 1;
}
if (h_ix >= GCOV_HISTOGRAM_SIZE)
gcov_error ("corrupted profile info: summary histogram "
"index is corrupt");
csum->histogram[h_ix].num_counters = gcov_read_unsigned ();
csum->histogram[h_ix].min_value = gcov_read_counter ();
csum->histogram[h_ix].cum_value = gcov_read_counter ();
/* Shift off the index we are done with and increment to the
corresponding next histogram entry. */
cur_bitvector >>= 1;
h_ix++;
}
}
bv_ix = 0;
h_ix = 0;
cur_bitvector = 0;
while (h_cnt--)
{
/* Find the index corresponding to the next entry we will read in.
First find the next non-zero bitvector and re-initialize
the histogram index accordingly, then right shift and increment
the index until we find a set bit. */
while (!cur_bitvector)
{
h_ix = bv_ix * 32;
if (bv_ix >= GCOV_HISTOGRAM_BITVECTOR_SIZE)
gcov_error ("corrupted profile info: summary histogram "
"bitvector is corrupt");
cur_bitvector = histo_bitvector[bv_ix++];
}
while (!(cur_bitvector & 0x1))
{
h_ix++;
cur_bitvector >>= 1;
}
if (h_ix >= GCOV_HISTOGRAM_SIZE)
gcov_error ("corrupted profile info: summary histogram "
"index is corrupt");
summary->histogram[h_ix].num_counters = gcov_read_unsigned ();
summary->histogram[h_ix].min_value = gcov_read_counter ();
summary->histogram[h_ix].cum_value = gcov_read_counter ();
/* Shift off the index we are done with and increment to the
corresponding next histogram entry. */
cur_bitvector >>= 1;
h_ix++;
}
}
......@@ -921,7 +907,7 @@ static void gcov_histogram_merge (gcov_bucket_type *tgt_histo,
the minimum counter value in that working set. */
GCOV_LINKAGE void
compute_working_sets (const struct gcov_ctr_summary *summary,
compute_working_sets (const gcov_summary *summary,
gcov_working_set_t *gcov_working_sets)
{
gcov_type working_set_cum_values[NUM_GCOV_WORKING_SETS];
......
......@@ -140,9 +140,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
int32:lineno_checksum int32:cfg_checksum
present: header int32:present
counts: header int64:count*
summary: int32:checksum {count-summary}GCOV_COUNTERS_SUMMABLE
count-summary: int32:num int32:runs int64:sum
int64:max int64:sum_max histogram
summary: int32:checksum int32:num int32:runs int64:sum
int64:max int64:sum_max histogram
histogram: {int32:bitvector}8 histogram-buckets*
histogram-buckets: int32:num int64:min int64:sum
......@@ -243,8 +242,7 @@ typedef uint64_t gcov_type_unsigned;
#define GCOV_TAG_COUNTER_NUM(LENGTH) ((LENGTH) / 2)
#define GCOV_TAG_OBJECT_SUMMARY ((gcov_unsigned_t)0xa1000000) /* Obsolete */
#define GCOV_TAG_PROGRAM_SUMMARY ((gcov_unsigned_t)0xa3000000)
#define GCOV_TAG_SUMMARY_LENGTH(NUM) \
(1 + GCOV_COUNTERS_SUMMABLE * (10 + 3 * 2) + (NUM) * 5)
#define GCOV_TAG_SUMMARY_LENGTH(NUM) (1 + (10 + 3 * 2) + (NUM) * 5)
#define GCOV_TAG_AFDO_FILE_NAMES ((gcov_unsigned_t)0xaa000000)
#define GCOV_TAG_AFDO_FUNCTION ((gcov_unsigned_t)0xac000000)
#define GCOV_TAG_AFDO_WORKING_SET ((gcov_unsigned_t)0xaf000000)
......@@ -259,13 +257,10 @@ GCOV_COUNTERS
};
#undef DEF_GCOV_COUNTER
/* Counters which can be summaried. */
#define GCOV_COUNTERS_SUMMABLE (GCOV_COUNTER_ARCS + 1)
/* The first of counters used for value profiling. They must form a
consecutive interval and their order must match the order of
HIST_TYPEs in value-prof.h. */
#define GCOV_FIRST_VALUE_COUNTER GCOV_COUNTERS_SUMMABLE
#define GCOV_FIRST_VALUE_COUNTER GCOV_COUNTER_V_INTERVAL
/* The last of counters used for value profiling. */
#define GCOV_LAST_VALUE_COUNTER (GCOV_COUNTERS - 1)
......@@ -337,23 +332,18 @@ typedef struct
This is essentially a ceiling divide by 32 bits. */
#define GCOV_HISTOGRAM_BITVECTOR_SIZE (GCOV_HISTOGRAM_SIZE + 31) / 32
/* Cumulative counter data. */
struct gcov_ctr_summary
{
gcov_unsigned_t num; /* number of counters. */
gcov_unsigned_t runs; /* number of program runs */
gcov_type sum_all; /* sum of all counters accumulated. */
gcov_type run_max; /* maximum value on a single run. */
gcov_type sum_max; /* sum of individual run max values. */
gcov_bucket_type histogram[GCOV_HISTOGRAM_SIZE]; /* histogram of
counter values. */
};
/* Object & program summary record. */
struct gcov_summary
{
gcov_unsigned_t checksum; /* checksum of program */
struct gcov_ctr_summary ctrs[GCOV_COUNTERS_SUMMABLE];
gcov_unsigned_t checksum; /* Checksum of program. */
gcov_unsigned_t num; /* Number of counters. */
gcov_unsigned_t runs; /* Number of program runs. */
gcov_type sum_all; /* Sum of all counters accumulated. */
gcov_type run_max; /* Maximum value on a single run. */
gcov_type sum_max; /* Sum of individual run max values. */
gcov_bucket_type histogram[GCOV_HISTOGRAM_SIZE]; /* Histogram of
counter values. */
};
#if !defined(inhibit_libc)
......@@ -414,7 +404,7 @@ typedef struct gcov_working_set_info
gcov_type min_counter;
} gcov_working_set_t;
GCOV_LINKAGE void compute_working_sets (const struct gcov_ctr_summary *summary,
GCOV_LINKAGE void compute_working_sets (const gcov_summary *summary,
gcov_working_set_t *gcov_working_sets);
#endif
......
......@@ -1801,7 +1801,7 @@ read_count_file (void)
{
struct gcov_summary summary;
gcov_read_summary (&summary);
object_runs += summary.ctrs[GCOV_COUNTER_ARCS].runs;
object_runs += summary.runs;
program_count++;
}
else if (tag == GCOV_TAG_FUNCTION && !length)
......
......@@ -1657,7 +1657,7 @@ input_refs (struct lto_input_block *ib,
}
static struct gcov_ctr_summary lto_gcov_summary;
static gcov_summary lto_gcov_summary;
/* Input profile_info from IB. */
static void
......@@ -1715,7 +1715,7 @@ merge_profile_summaries (struct lto_file_decl_data **file_data_vec)
struct cgraph_node *node;
struct cgraph_edge *edge;
gcov_type saved_sum_all = 0;
gcov_ctr_summary *saved_profile_info = 0;
gcov_summary *saved_profile_info = 0;
int saved_scale = 0;
/* Find unit with maximal number of runs. If we ever get serious about
......
......@@ -582,7 +582,7 @@ struct GTY(()) lto_file_decl_data
vec<res_pair> GTY((skip)) respairs;
unsigned max_index;
struct gcov_ctr_summary GTY((skip)) profile_info;
gcov_summary GTY((skip)) profile_info;
/* Map assigning declarations their resolutions. */
hash_map<tree, ld_plugin_symbol_resolution> * GTY((skip)) resolution_map;
......
......@@ -84,7 +84,7 @@ struct bb_profile_info {
/* Counter summary from the last set of coverage counts read. */
const struct gcov_ctr_summary *profile_info;
const gcov_summary *profile_info;
/* Counter working set information computed from the current counter
summary. Not initialized unless profile_info summary is non-NULL. */
......
......@@ -75,6 +75,6 @@ extern void get_working_sets (void);
/* Counter summary from the last set of coverage counts read by
profile.c. */
extern const struct gcov_ctr_summary *profile_info;
extern const struct gcov_summary *profile_info;
#endif /* PROFILE_H */
2018-06-05 Martin Liska <mliska@suse.cz>
* libgcov-driver.c (gcov_compute_histogram): Remove usage
of gcov_ctr_summary.
(compute_summary): Do it just for a single summary.
(merge_one_data): Likewise.
(merge_summary): Simplify as we read just single summary.
(dump_one_gcov): Pass proper argument.
* libgcov-util.c (compute_one_gcov): Simplify as we have just
single summary.
(gcov_info_count_all_cold): Likewise.
(calculate_overlap): Likewise.
2018-06-02 Chung-Ju Wu <jasonwucj@gmail.com>
Monk Chiang <sh.chiang04@gmail.com>
......
......@@ -221,40 +221,24 @@ gcov_compute_histogram (struct gcov_info *list, struct gcov_summary *sum)
struct gcov_info *gi_ptr;
const struct gcov_fn_info *gfi_ptr;
const struct gcov_ctr_info *ci_ptr;
struct gcov_ctr_summary *cs_ptr;
unsigned t_ix, f_ix, ctr_info_ix, ix;
unsigned f_ix, ix;
int h_ix;
/* This currently only applies to arc counters. */
t_ix = GCOV_COUNTER_ARCS;
/* First check if there are any counts recorded for this counter. */
cs_ptr = &(sum->ctrs[t_ix]);
if (!cs_ptr->num)
if (!sum->num)
return;
for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
{
cs_ptr->histogram[h_ix].num_counters = 0;
cs_ptr->histogram[h_ix].min_value = cs_ptr->run_max;
cs_ptr->histogram[h_ix].cum_value = 0;
sum->histogram[h_ix].num_counters = 0;
sum->histogram[h_ix].min_value = sum->run_max;
sum->histogram[h_ix].cum_value = 0;
}
/* Walk through all the per-object structures and record each of
the count values in histogram. */
for (gi_ptr = list; gi_ptr; gi_ptr = gi_ptr->next)
{
if (!gi_ptr->merge[t_ix])
continue;
/* Find the appropriate index into the gcov_ctr_info array
for the counter we are currently working on based on the
existence of the merge function pointer for this object. */
for (ix = 0, ctr_info_ix = 0; ix < t_ix; ix++)
{
if (gi_ptr->merge[ix])
ctr_info_ix++;
}
for (f_ix = 0; f_ix != gi_ptr->n_functions; f_ix++)
{
gfi_ptr = gi_ptr->functions[f_ix];
......@@ -262,9 +246,9 @@ gcov_compute_histogram (struct gcov_info *list, struct gcov_summary *sum)
if (!gfi_ptr || gfi_ptr->key != gi_ptr)
continue;
ci_ptr = &gfi_ptr->ctrs[ctr_info_ix];
for (ix = 0; ix < ci_ptr->num; ix++)
gcov_histogram_insert (cs_ptr->histogram, ci_ptr->values[ix]);
ci_ptr = &gfi_ptr->ctrs[0];
for (ix = 0; ix < ci_ptr->num; ix++)
gcov_histogram_insert (sum->histogram, ci_ptr->values[ix]);
}
}
}
......@@ -287,10 +271,8 @@ compute_summary (struct gcov_info *list, struct gcov_summary *this_prg,
{
struct gcov_info *gi_ptr;
const struct gcov_fn_info *gfi_ptr;
struct gcov_ctr_summary *cs_ptr;
const struct gcov_ctr_info *ci_ptr;
int f_ix;
unsigned t_ix;
gcov_unsigned_t c_num;
gcov_unsigned_t crc32 = 0;
......@@ -319,25 +301,18 @@ compute_summary (struct gcov_info *list, struct gcov_summary *this_prg,
if (!gfi_ptr)
continue;
ci_ptr = gfi_ptr->ctrs;
for (t_ix = 0; t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++)
{
if (!gi_ptr->merge[t_ix])
continue;
cs_ptr = &(this_prg->ctrs[t_ix]);
cs_ptr->num += ci_ptr->num;
crc32 = crc32_unsigned (crc32, ci_ptr->num);
for (c_num = 0; c_num < ci_ptr->num; c_num++)
{
cs_ptr->sum_all += ci_ptr->values[c_num];
if (cs_ptr->run_max < ci_ptr->values[c_num])
cs_ptr->run_max = ci_ptr->values[c_num];
}
ci_ptr++;
}
}
ci_ptr = gfi_ptr->ctrs;
this_prg->num += ci_ptr->num;
crc32 = crc32_unsigned (crc32, ci_ptr->num);
for (c_num = 0; c_num < ci_ptr->num; c_num++)
{
this_prg->sum_all += ci_ptr->values[c_num];
if (this_prg->run_max < ci_ptr->values[c_num])
this_prg->run_max = ci_ptr->values[c_num];
}
ci_ptr++;
}
}
gcov_compute_histogram (list, this_prg);
return crc32;
......@@ -411,9 +386,8 @@ merge_one_data (const char *filename,
if (tmp.checksum != crc32)
goto next_summary;
for (t_ix = 0; t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++)
if (tmp.ctrs[t_ix].num != this_prg->ctrs[t_ix].num)
goto next_summary;
if (tmp.num != this_prg->num)
goto next_summary;
*prg_p = tmp;
*summary_pos_p = *eof_pos_p;
......@@ -600,77 +574,60 @@ write_one_data (const struct gcov_info *gi_ptr,
Return -1 on error. Return 0 on success. */
static int
merge_summary (const char *filename, int run_counted,
const struct gcov_info *gi_ptr, struct gcov_summary *prg,
merge_summary (const char *filename __attribute__ ((unused)), int run_counted,
struct gcov_summary *prg,
struct gcov_summary *this_prg, gcov_unsigned_t crc32,
struct gcov_summary *all_prg __attribute__ ((unused)))
{
struct gcov_ctr_summary *cs_prg, *cs_tprg;
unsigned t_ix;
#if !GCOV_LOCKED
/* summary for all instances of program. */
struct gcov_ctr_summary *cs_all;
struct gcov_summary *cs_all;
#endif
/* Merge the summaries. */
for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
{
cs_prg = &(prg->ctrs[t_ix]);
cs_tprg = &(this_prg->ctrs[t_ix]);
if (gi_ptr->merge[t_ix])
{
int first = !cs_prg->runs;
if (!run_counted)
cs_prg->runs++;
if (first)
cs_prg->num = cs_tprg->num;
cs_prg->sum_all += cs_tprg->sum_all;
if (cs_prg->run_max < cs_tprg->run_max)
cs_prg->run_max = cs_tprg->run_max;
cs_prg->sum_max += cs_tprg->run_max;
if (first)
memcpy (cs_prg->histogram, cs_tprg->histogram,
sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
else
gcov_histogram_merge (cs_prg->histogram, cs_tprg->histogram);
}
else if (cs_prg->runs)
{
gcov_error ("profiling:%s:Merge mismatch for summary.\n",
filename);
return -1;
}
/* Merge the summary. */
int first = !prg->runs;
if (!run_counted)
prg->runs++;
if (first)
prg->num = this_prg->num;
prg->sum_all += this_prg->sum_all;
if (prg->run_max < this_prg->run_max)
prg->run_max = this_prg->run_max;
prg->sum_max += this_prg->run_max;
if (first)
memcpy (prg->histogram, this_prg->histogram,
sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
else
gcov_histogram_merge (prg->histogram, this_prg->histogram);
#if !GCOV_LOCKED
cs_all = &all_prg->ctrs[t_ix];
if (!cs_all->runs && cs_prg->runs)
{
cs_all->num = cs_prg->num;
cs_all->runs = cs_prg->runs;
cs_all->sum_all = cs_prg->sum_all;
cs_all->run_max = cs_prg->run_max;
cs_all->sum_max = cs_prg->sum_max;
}
else if (!all_prg->checksum
/* Don't compare the histograms, which may have slight
variations depending on the order they were updated
due to the truncating integer divides used in the
merge. */
&& (cs_all->num != cs_prg->num
|| cs_all->runs != cs_prg->runs
|| cs_all->sum_all != cs_prg->sum_all
|| cs_all->run_max != cs_prg->run_max
|| cs_all->sum_max != cs_prg->sum_max))
{
gcov_error ("profiling:%s:Data file mismatch - some "
"data files may have been concurrently "
"updated without locking support\n", filename);
all_prg->checksum = ~0u;
}
#endif
all = &all_prg->ctrs[t_ix];
if (!all->runs && prg->runs)
{
all->num = prg->num;
all->runs = prg->runs;
all->sum_all = prg->sum_all;
all->run_max = prg->run_max;
all->sum_max = prg->sum_max;
}
else if (!all_prg->checksum
/* Don't compare the histograms, which may have slight
variations depending on the order they were updated
due to the truncating integer divides used in the
merge. */
&& (all->num != prg->num
|| all->runs != prg->runs
|| all->sum_all != prg->sum_all
|| all->run_max != prg->run_max
|| all->sum_max != prg->sum_max))
{
gcov_error ("profiling:%s:Data file mismatch - some "
"data files may have been concurrently "
"updated without locking support\n", filename);
all_prg->checksum = ~0u;
}
#endif
prg->checksum = crc32;
return 0;
......@@ -806,7 +763,7 @@ dump_one_gcov (struct gcov_info *gi_ptr, struct gcov_filename *gf,
summary_pos = eof_pos;
}
error = merge_summary (gf->filename, run_counted, gi_ptr, &prg, this_prg,
error = merge_summary (gf->filename, run_counted, &prg, this_prg,
crc32, all_prg);
if (error == -1)
goto read_fatal;
......
......@@ -930,24 +930,13 @@ compute_one_gcov (const struct gcov_info *gcov_info1,
{
for (f_ix = 0; f_ix < gcov_info->n_functions; f_ix++)
{
unsigned t_ix;
const struct gcov_fn_info *gfi_ptr = gcov_info->functions[f_ix];
if (!gfi_ptr || gfi_ptr->key != gcov_info)
continue;
const struct gcov_ctr_info *ci_ptr = gfi_ptr->ctrs;
for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
{
unsigned c_num;
if (!gcov_info->merge[t_ix])
continue;
for (c_num = 0; c_num < ci_ptr->num; c_num++)
{
cum_1 += ci_ptr->values[c_num] / sum;
}
ci_ptr++;
}
unsigned c_num;
for (c_num = 0; c_num < ci_ptr->num; c_num++)
cum_1 += ci_ptr->values[c_num] / sum;
}
*cum_p = cum_1;
return 0.0;
......@@ -955,7 +944,6 @@ compute_one_gcov (const struct gcov_info *gcov_info1,
for (f_ix = 0; f_ix < gcov_info1->n_functions; f_ix++)
{
unsigned t_ix;
double func_cum_1 = 0.0;
double func_cum_2 = 0.0;
double func_val = 0.0;
......@@ -971,32 +959,24 @@ compute_one_gcov (const struct gcov_info *gcov_info1,
const struct gcov_ctr_info *ci_ptr1 = gfi_ptr1->ctrs;
const struct gcov_ctr_info *ci_ptr2 = gfi_ptr2->ctrs;
for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
{
unsigned c_num;
unsigned c_num;
for (c_num = 0; c_num < ci_ptr1->num; c_num++)
{
if (ci_ptr1->values[c_num] | ci_ptr2->values[c_num])
{
func_val += calculate_2_entries (ci_ptr1->values[c_num],
ci_ptr2->values[c_num],
sum_1, sum_2);
func_cum_1 += ci_ptr1->values[c_num] / sum_1;
func_cum_2 += ci_ptr2->values[c_num] / sum_2;
nonzero = 1;
if (ci_ptr1->values[c_num] / sum_1 >= overlap_hot_threshold
|| ci_ptr2->values[c_num] / sum_2 >= overlap_hot_threshold)
hot = 1;
}
}
if (!gcov_info1->merge[t_ix])
continue;
for (c_num = 0; c_num < ci_ptr1->num; c_num++)
{
if (ci_ptr1->values[c_num] | ci_ptr2->values[c_num])
{
func_val += calculate_2_entries (ci_ptr1->values[c_num],
ci_ptr2->values[c_num],
sum_1, sum_2);
func_cum_1 += ci_ptr1->values[c_num] / sum_1;
func_cum_2 += ci_ptr2->values[c_num] / sum_2;
nonzero = 1;
if (ci_ptr1->values[c_num] / sum_1 >= overlap_hot_threshold ||
ci_ptr2->values[c_num] / sum_2 >= overlap_hot_threshold)
hot = 1;
}
}
ci_ptr1++;
ci_ptr2++;
}
ret += func_val;
cum_1 += func_cum_1;
cum_2 += func_cum_2;
......@@ -1023,26 +1003,14 @@ gcov_info_count_all_cold (const struct gcov_info *gcov_info,
for (f_ix = 0; f_ix < gcov_info->n_functions; f_ix++)
{
unsigned t_ix;
const struct gcov_fn_info *gfi_ptr = gcov_info->functions[f_ix];
if (!gfi_ptr || gfi_ptr->key != gcov_info)
continue;
const struct gcov_ctr_info *ci_ptr = gfi_ptr->ctrs;
for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
{
unsigned c_num;
if (!gcov_info->merge[t_ix])
continue;
for (c_num = 0; c_num < ci_ptr->num; c_num++)
{
if (ci_ptr->values[c_num] > threshold)
return false;
}
ci_ptr++;
}
for (unsigned c_num = 0; c_num < ci_ptr->num; c_num++)
if (ci_ptr->values[c_num] > threshold)
return false;
}
return true;
......@@ -1252,13 +1220,13 @@ calculate_overlap (struct gcov_info *gcov_list1,
struct overlap_t *all_infos;
compute_summary (gcov_list1, &this_prg, &max_length);
overlap_sum_1 = (double) (this_prg.ctrs[0].sum_all);
p1_sum_all = this_prg.ctrs[0].sum_all;
p1_run_max = this_prg.ctrs[0].run_max;
overlap_sum_1 = (double) (this_prg.sum_all);
p1_sum_all = this_prg.sum_all;
p1_run_max = this_prg.run_max;
compute_summary (gcov_list2, &this_prg, &max_length);
overlap_sum_2 = (double) (this_prg.ctrs[0].sum_all);
p2_sum_all = this_prg.ctrs[0].sum_all;
p2_run_max = this_prg.ctrs[0].run_max;
overlap_sum_2 = (double) (this_prg.sum_all);
p2_sum_all = this_prg.sum_all;
p2_run_max = this_prg.run_max;
for (gi_ptr = gcov_list1; gi_ptr; gi_ptr = gi_ptr->next)
list1_cnt++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment