This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[google] [4.6] fix a bug in capping bb count scaling (issue5786054)


Hi,

This patch is for google-4_6 branch only.

It fixes a bug in r184378 which makes some capping escape (like
stale max_bb_count in cgraph node).

Tested with the internal benchmark that exposes this issue.
Tested with gcc bootstrap.

-Rong

2012-03-08   Rong Xu  <xur@google.com>

	* gcc/tree-inline.c (copy_cfg_body): fix the bug in r184378.
          Google ref b/6105259.

Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c	(revision 185095)
+++ gcc/tree-inline.c	(working copy)
@@ -2210,7 +2210,7 @@
       struct cgraph_node *node = cgraph_node (callee_fndecl);
       double f_max;
       gcov_type max_count_scale;
-      gcov_type max_src_bb_cnt;
+      gcov_type max_src_bb_cnt = 0;
       gcov_type max_value = ((gcov_type) 1 << ((sizeof(gcov_type) * 8) - 1));
       max_value = ~max_value;
       count_scale = (REG_BR_PROB_BASE * (double)count
@@ -2220,14 +2220,13 @@
          This can happen for comdat functions where the counters are split.
          It's more likely for recursive inlines.  */
       gcc_assert (node);
-      max_src_bb_cnt = node->max_bb_count;
 
       /* Find the maximum count value to that will be copied.  */
       FOR_EACH_BB_FN (bb, cfun_to_copy)
         if (!blocks_to_copy || bitmap_bit_p (blocks_to_copy, bb->index))
           {
-            if (bb->count > node->max_bb_count)
-              max_src_bb_cnt = node->max_bb_count;
+            if (bb->count > max_src_bb_cnt)
+              max_src_bb_cnt = bb->count;
           }
 
       f_max = (double) max_value * REG_BR_PROB_BASE / max_src_bb_cnt - 1;

--
This patch is available for review at http://codereview.appspot.com/5786054


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]