re PR gcov-profile/55551 (Revision 193999 breaks lto/profiledbootstrap)

2012-12-02  Teresa Johnson  <tejohnson@google.com>

        PR gcov-profile/55551
	* lto-cgraph.c (merge_profile_summaries): Handle scaled histogram
        entries that map to the same index.

From-SVN: r194055
This commit is contained in:
Teresa Johnson 2012-12-02 16:40:28 +00:00 committed by Teresa Johnson
parent 853f8f1c1c
commit bde8c9629a
2 changed files with 15 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2012-12-02 Teresa Johnson <tejohnson@google.com>
PR gcov-profile/55551
* lto-cgraph.c (merge_profile_summaries): Handle scaled histogram
entries that map to the same index.
2012-12-02 Steven Bosscher <steven@gcc.gnu.org> 2012-12-02 Steven Bosscher <steven@gcc.gnu.org>
* optabs.c (add_equal_note): Do not create self-referencing REG_EQUAL * optabs.c (add_equal_note): Do not create self-referencing REG_EQUAL

View File

@ -1345,7 +1345,8 @@ merge_profile_summaries (struct lto_file_decl_data **file_data_vec)
/* Save a pointer to the profile_info with the largest /* Save a pointer to the profile_info with the largest
scaled sum_all and the scale for use in merging the scaled sum_all and the scale for use in merging the
histogram. */ histogram. */
if (lto_gcov_summary.sum_all > saved_sum_all) if (!saved_profile_info
|| lto_gcov_summary.sum_all > saved_sum_all)
{ {
saved_profile_info = &file_data->profile_info; saved_profile_info = &file_data->profile_info;
saved_sum_all = lto_gcov_summary.sum_all; saved_sum_all = lto_gcov_summary.sum_all;
@ -1363,17 +1364,20 @@ merge_profile_summaries (struct lto_file_decl_data **file_data_vec)
above. Use that to find the new histogram index. */ above. Use that to find the new histogram index. */
int scaled_min = RDIV (saved_profile_info->histogram[h_ix].min_value int scaled_min = RDIV (saved_profile_info->histogram[h_ix].min_value
* saved_scale, REG_BR_PROB_BASE); * saved_scale, REG_BR_PROB_BASE);
/* The new index may be shared with another scaled histogram entry,
so we need to account for a non-zero histogram entry at new_ix. */
unsigned new_ix = gcov_histo_index (scaled_min); unsigned new_ix = gcov_histo_index (scaled_min);
lto_gcov_summary.histogram[new_ix].min_value = scaled_min; lto_gcov_summary.histogram[new_ix].min_value
= MIN (lto_gcov_summary.histogram[new_ix].min_value, scaled_min);
/* Some of the scaled counter values would ostensibly need to be placed /* Some of the scaled counter values would ostensibly need to be placed
into different (larger) histogram buckets, but we keep things simple into different (larger) histogram buckets, but we keep things simple
here and place the scaled cumulative counter value in the bucket here and place the scaled cumulative counter value in the bucket
corresponding to the scaled minimum counter value. */ corresponding to the scaled minimum counter value. */
lto_gcov_summary.histogram[new_ix].cum_value lto_gcov_summary.histogram[new_ix].cum_value
= RDIV (saved_profile_info->histogram[h_ix].cum_value += RDIV (saved_profile_info->histogram[h_ix].cum_value
* saved_scale, REG_BR_PROB_BASE); * saved_scale, REG_BR_PROB_BASE);
lto_gcov_summary.histogram[new_ix].num_counters lto_gcov_summary.histogram[new_ix].num_counters
= saved_profile_info->histogram[h_ix].num_counters; += saved_profile_info->histogram[h_ix].num_counters;
} }
/* Watch roundoff errors. */ /* Watch roundoff errors. */