aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2018-06-05 10:13:31 +0200
committerMartin Liska <marxin@gcc.gnu.org>2018-06-05 08:13:31 +0000
commit7f3577f5285957c1aa48823ce6c691f8c212b219 (patch)
tree5127bd697a20fb3805447c7cd1857b52f04112ae /libgcc
parent632b10e14156db1e429f623628ad4f270c1550c4 (diff)
downloadgcc-7f3577f5285957c1aa48823ce6c691f8c212b219.zip
gcc-7f3577f5285957c1aa48823ce6c691f8c212b219.tar.gz
gcc-7f3577f5285957c1aa48823ce6c691f8c212b219.tar.bz2
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
Diffstat (limited to 'libgcc')
-rw-r--r--libgcc/ChangeLog13
-rw-r--r--libgcc/libgcov-driver.c179
-rw-r--r--libgcc/libgcov-util.c90
3 files changed, 110 insertions, 172 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index d75d934..f2297c0 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,16 @@
+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>
diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index 6103563..922d9dd 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -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;
diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c
index 9cf56a8..1d26176 100644
--- a/libgcc/libgcov-util.c
+++ b/libgcc/libgcov-util.c
@@ -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++;