From 8b5d71cd61ecf0793cab732aad7232d6da4620fc Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Wed, 19 Jul 2017 18:09:39 +0000 Subject: predict.c (propagate_unlikely_bbs_forward): Break out from ... * predict.c (propagate_unlikely_bbs_forward): Break out from ... (determine_unlikely_bbs): ... here. * predict.h (propagate_unlikely_bbs_forward): Declare. * cfgexpand.c (pass_expand::execute): Use it. * bb-reorder.c (sanitize_hot_paths): Do not consider known to be unlikely edges. (find_rarely_executed_basic_blocks_and_crossing_edges): Use propagate_unlikely_bbs_forward. From-SVN: r250360 --- gcc/bb-reorder.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gcc/bb-reorder.c') diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c index a421f6b..17a1ea3 100644 --- a/gcc/bb-reorder.c +++ b/gcc/bb-reorder.c @@ -1525,6 +1525,11 @@ sanitize_hot_paths (bool walk_up, unsigned int cold_bb_count, if (e->flags & EDGE_DFS_BACK) continue; + /* Do not expect profile insanities when profile was not adjusted. */ + if (e->probability == profile_probability::never () + || e->count == profile_count::zero ()) + continue; + if (BB_PARTITION (reach_bb) != BB_COLD_PARTITION) { found = true; @@ -1555,6 +1560,10 @@ sanitize_hot_paths (bool walk_up, unsigned int cold_bb_count, { if (e->flags & EDGE_DFS_BACK) continue; + /* Do not expect profile insanities when profile was not adjusted. */ + if (e->probability == profile_probability::never () + || e->count == profile_count::zero ()) + continue; /* Select the hottest edge using the edge count, if it is non-zero, then fallback to the edge frequency and finally the edge probability. */ @@ -1576,6 +1585,10 @@ sanitize_hot_paths (bool walk_up, unsigned int cold_bb_count, /* We have a hot bb with an immediate dominator that is cold. The dominator needs to be re-marked hot. */ BB_SET_PARTITION (reach_bb, BB_HOT_PARTITION); + if (dump_file) + fprintf (dump_file, "Promoting bb %i to hot partition to sanitize " + "profile of bb %i in %s walk\n", reach_bb->index, + bb->index, walk_up ? "backward" : "forward"); cold_bb_count--; /* Now we need to examine newly-hot reach_bb to see if it is also @@ -1603,6 +1616,8 @@ find_rarely_executed_basic_blocks_and_crossing_edges (void) unsigned int cold_bb_count = 0; auto_vec bbs_in_hot_partition; + propagate_unlikely_bbs_forward (); + /* Mark which partition (hot/cold) each basic block belongs in. */ FOR_EACH_BB_FN (bb, cfun) { -- cgit v1.1