Hi, calls to functions that will not return cause profile to look locally incorrect. (because the sum of outgoing frequencies does not match the BB frequency). Do not report that. This makes it easier to analyze C++ sources. On tramp3d we now have about 20 mismatches caused by loop unroling about about 1200 caused by jump threading.
Bootstrapped/regtested x86_64-linux. Honza * cfg.c (check_bb_profile): Do not report mismatched profiles when only edges out of BB are EH edges. Index: cfg.c =================================================================== --- cfg.c (revision 237097) +++ cfg.c (working copy) @@ -412,20 +412,31 @@ check_bb_profile (basic_block bb, FILE * if (bb != EXIT_BLOCK_PTR_FOR_FN (fun)) { + bool found = false; FOR_EACH_EDGE (e, ei, bb->succs) - sum += e->probability; - if (EDGE_COUNT (bb->succs) && abs (sum - REG_BR_PROB_BASE) > 100) - fprintf (file, "%s%sInvalid sum of outgoing probabilities %.1f%%\n", - (flags & TDF_COMMENT) ? ";; " : "", s_indent, - sum * 100.0 / REG_BR_PROB_BASE); - lsum = 0; - FOR_EACH_EDGE (e, ei, bb->succs) - lsum += e->count; - if (EDGE_COUNT (bb->succs) - && (lsum - bb->count > 100 || lsum - bb->count < -100)) - fprintf (file, "%s%sInvalid sum of outgoing counts %i, should be %i\n", - (flags & TDF_COMMENT) ? ";; " : "", s_indent, - (int) lsum, (int) bb->count); + { + if (!(e->flags & EDGE_EH)) + found = true; + sum += e->probability; + } + /* Only report mismatches for non-EH control flow. If there are only EH + edges it means that the BB ends by noreturn call. Here the control + flow may just terminate. */ + if (found) + { + if (EDGE_COUNT (bb->succs) && abs (sum - REG_BR_PROB_BASE) > 100) + fprintf (file, "%s%sInvalid sum of outgoing probabilities %.1f%%\n", + (flags & TDF_COMMENT) ? ";; " : "", s_indent, + sum * 100.0 / REG_BR_PROB_BASE); + lsum = 0; + FOR_EACH_EDGE (e, ei, bb->succs) + lsum += e->count; + if (EDGE_COUNT (bb->succs) + && (lsum - bb->count > 100 || lsum - bb->count < -100)) + fprintf (file, "%s%sInvalid sum of outgoing counts %i, should be %i\n", + (flags & TDF_COMMENT) ? ";; " : "", s_indent, + (int) lsum, (int) bb->count); + } } if (bb != ENTRY_BLOCK_PTR_FOR_FN (fun)) {