aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-profile.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ipa-profile.cc')
-rw-r--r--gcc/ipa-profile.cc24
1 files changed, 16 insertions, 8 deletions
diff --git a/gcc/ipa-profile.cc b/gcc/ipa-profile.cc
index 0863866..c8b8529 100644
--- a/gcc/ipa-profile.cc
+++ b/gcc/ipa-profile.cc
@@ -764,7 +764,8 @@ ipa_profile (void)
int order_pos;
bool something_changed = false;
int i;
- gcov_type overall_time = 0, cutoff = 0, cumulated = 0, overall_size = 0;
+ widest_int overall_time = 0, cumulated = 0;
+ gcov_type overall_size = 0;
struct cgraph_node *n,*n2;
int nindirect = 0, ncommon = 0, nunknown = 0, nuseless = 0, nconverted = 0;
int nmismatch = 0, nimpossible = 0;
@@ -775,37 +776,44 @@ ipa_profile (void)
dump_histogram (dump_file, histogram);
for (i = 0; i < (int)histogram.length (); i++)
{
- overall_time += histogram[i]->count * histogram[i]->time;
+ overall_time += ((widest_int)histogram[i]->count) * histogram[i]->time;
+ /* Watch for overflow. */
+ gcc_assert (overall_time >= 0);
overall_size += histogram[i]->size;
}
threshold = 0;
- if (overall_time)
+ if (overall_time != 0)
{
gcc_assert (overall_size);
- cutoff = (overall_time * param_hot_bb_count_ws_permille + 500) / 1000;
+ widest_int cutoff = ((overall_time * param_hot_bb_count_ws_permille
+ + 500) / 1000);
+ /* Watch for overflow. */
+ gcc_assert (cutoff >= 0);
for (i = 0; cumulated < cutoff; i++)
{
- cumulated += histogram[i]->count * histogram[i]->time;
+ cumulated += ((widest_int)histogram[i]->count) * histogram[i]->time;
threshold = histogram[i]->count;
}
if (!threshold)
threshold = 1;
if (dump_file)
{
- gcov_type cumulated_time = 0, cumulated_size = 0;
+ widest_int cumulated_time = 0;
+ gcov_type cumulated_size = 0;
for (i = 0;
i < (int)histogram.length () && histogram[i]->count >= threshold;
i++)
{
- cumulated_time += histogram[i]->count * histogram[i]->time;
+ cumulated_time += ((widest_int)histogram[i]->count)
+ * histogram[i]->time;
cumulated_size += histogram[i]->size;
}
fprintf (dump_file, "Determined min count: %" PRId64
" Time:%3.2f%% Size:%3.2f%%\n",
(int64_t)threshold,
- cumulated_time * 100.0 / overall_time,
+ (cumulated_time * 10000 / overall_time).to_shwi () / 100.0,
cumulated_size * 100.0 / overall_size);
}