I have seen an ICE in 4.4.3 when a corrupted profile file causes a
division by 0 in gcc. This is the equivalent code in trunk and this
check should help fix it.
Thoughts?

2011-03-15  Ahmad Sharif  <asha...@google.com>

       * predict.c (probably_never_executed_bb_p): Add check to see
       whether profile_info->runs is equal to 0 before doing the division.
Index: predict.c
===================================================================
--- predict.c (revision 171019)
+++ predict.c (working copy)
@@ -200,7 +200,7 @@
 bool
 probably_never_executed_bb_p (const_basic_block bb)
 {
-  if (profile_info && flag_branch_probabilities)
+  if (profile_info && flag_branch_probabilities && profile_info->runs != 0)
     return ((bb->count + profile_info->runs / 2) / profile_info->runs) == 0;
   if ((!profile_info || !flag_branch_probabilities)
       && cgraph_node (current_function_decl)->frequency ==
NODE_FREQUENCY_UNLIKELY_EXECUTED)

Reply via email to