* tree-cfg.c (gimple_find_sub_bbs): Fix profile updating.
authorJan Hubicka <hubicka@ucw.cz>
Mon, 3 Jul 2017 12:43:19 +0000 (14:43 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Mon, 3 Jul 2017 12:43:19 +0000 (12:43 +0000)
From-SVN: r249908

gcc/ChangeLog
gcc/tree-cfg.c

index 3d0826ae6c9ee4e05c777528199993b0b879b716..dd4c44bf03bc40e055a42bf94033bdc2cacb18c1 100644 (file)
@@ -1,3 +1,7 @@
+2017-07-02  Jan Hubicka  <hubicka@ucw.cz>
+
+       * tree-cfg.c (gimple_find_sub_bbs): Fix profile updating.
+
 2017-07-02  Jan Hubicka  <hubicka@ucw.cz>
 
        * tree-cfgcleanup.c (want_merge_blocks_p): New function.
index e0cee12a69ebf12d0ffd756f3c586fd8c2963ae5..248373194f5eb49d0957df97a1af60109beec863 100644 (file)
@@ -1051,6 +1051,7 @@ gimple_find_sub_bbs (gimple_seq seq, gimple_stmt_iterator *gsi)
       struct omp_region *cur_region = NULL;
       profile_count cnt = profile_count::zero ();
       int freq = 0;
+      bool all = true;
 
       int cur_omp_region_idx = 0;
       int mer = make_edges_bb (bb, &cur_region, &cur_omp_region_idx);
@@ -1061,12 +1062,16 @@ gimple_find_sub_bbs (gimple_seq seq, gimple_stmt_iterator *gsi)
       edge_iterator ei;
       FOR_EACH_EDGE (e, ei, bb->preds)
        {
-         cnt += e->count;
+         if (e->count.initialized_p ())
+           cnt += e->count;
+         else
+           all = false;
          freq += EDGE_FREQUENCY (e);
        }
-      bb->count = cnt;
-      bb->frequency = freq;
       tree_guess_outgoing_edge_probabilities (bb);
+      if (all || profile_status_for_fn (cfun) == PROFILE_READ)
+        bb->count = cnt;
+      bb->frequency = freq;
       FOR_EACH_EDGE (e, ei, bb->succs)
        e->count = bb->count.apply_probability (e->probability);