]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* predict.c (propagate_unlikely_bbs_forward): Break out from ...
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 Jul 2017 18:09:39 +0000 (18:09 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 Jul 2017 18:09:39 +0000 (18:09 +0000)
(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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250360 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/bb-reorder.c
gcc/cfgexpand.c
gcc/predict.h

index a421f6b3c713e6f95f4fe05ac2b16b47d67c44df..17a1ea3ed8d8057e52d4f245869b84875a9e0b96 100644 (file)
@@ -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<basic_block> bbs_in_hot_partition;
 
+  propagate_unlikely_bbs_forward ();
+
   /* Mark which partition (hot/cold) each basic block belongs in.  */
   FOR_EACH_BB_FN (bb, cfun)
     {
index 3e1d24db876ee51d71337cd04c23f75d1fa211a8..c9d8118ed4526d9a307d5d3c25883b1c6cb60620 100644 (file)
@@ -6480,6 +6480,11 @@ pass_expand::execute (function *fun)
   if (fun->eh->region_tree != NULL)
     finish_eh_generation ();
 
+  /* BB subdivision may have created basic blocks that are are only reachable
+     from unlikely bbs but not marked as such in the profile.  */
+  if (optimize)
+    propagate_unlikely_bbs_forward ();
+
   /* Remove unreachable blocks, otherwise we cannot compute dominators
      which are needed for loop state verification.  As a side-effect
      this also compacts blocks.
index a6cf1ee70e18d6930e36138def7a745e256dd68a..9b8b14022e389444b0bc7a5278387a9c147bf74e 100644 (file)
@@ -98,6 +98,7 @@ extern const char *predictor_name (enum br_predictor);
 extern void rebuild_frequencies (void);
 extern void report_predictor_hitrates (void);
 extern void force_edge_cold (edge, bool);
+extern void propagate_unlikely_bbs_forward (void);
 
 extern void add_reg_br_prob_note (rtx_insn *, profile_probability);