From: Martin Liska Date: Fri, 24 Oct 2014 06:06:20 +0000 (+0200) Subject: ipa-icf.c (sem_item_optimizer::parse_nonsingleton_classes): Guard division by zero... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f1c859ee84ad2d44fa9fc1867b183c47ee1d0489;p=gcc.git ipa-icf.c (sem_item_optimizer::parse_nonsingleton_classes): Guard division by zero in dumps. * ipa-icf.c (sem_item_optimizer::parse_nonsingleton_classes): Guard division by zero in dumps. (sem_item_optimizer::merge_classes): Ditto. From-SVN: r216612 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4187dd9651f..cefe8ffab74 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-10-24 Martin Liska + + * ipa-icf.c (sem_item_optimizer::parse_nonsingleton_classes): Guard + division by zero in dumps. + (sem_item_optimizer::merge_classes): Ditto. + 2014-10-23 John David Anglin * config/pa/pa.c (pa_can_combine_p): Fix typo in last change. diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index d1238a4ce8b..e8c32c704d9 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -1736,7 +1736,7 @@ sem_item_optimizer::parse_nonsingleton_classes (void) if (dump_file) fprintf (dump_file, "Init called for %u items (%.2f%%).\n", init_called_count, - 100.0f * init_called_count / m_items.length ()); + m_items.length () ? 100.0f * init_called_count / m_items.length (): 0.0f); } /* Equality function for semantic items is used to subdivide existing @@ -2196,14 +2196,15 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count) fprintf (dump_file, "Congruent classes before: %u, after: %u\n", prev_class_count, class_count); fprintf (dump_file, "Average class size before: %.2f, after: %.2f\n", - 1.0f * item_count / prev_class_count, - 1.0f * item_count / class_count); + prev_class_count ? 1.0f * item_count / prev_class_count : 0.0f, + class_count ? 1.0f * item_count / class_count : 0.0f); fprintf (dump_file, "Average non-singular class size: %.2f, count: %u\n", - 1.0f * non_singular_classes_sum / non_singular_classes_count, + non_singular_classes_count ? 1.0f * non_singular_classes_sum / + non_singular_classes_count : 0.0f, non_singular_classes_count); fprintf (dump_file, "Equal symbols: %u\n", equal_items); fprintf (dump_file, "Fraction of visited symbols: %.2f%%\n\n", - 100.0f * equal_items / item_count); + item_count ? 100.0f * equal_items / item_count : 0.0f); } for (hash_table::iterator it = m_classes.begin ();