OSDN Git Service

2010-12-09 Yao Qi <yao@codesourcery.com>
[pf3gnuchains/gcc-fork.git] / gcc / lto-streamer-in.c
index f167d40..4fe9cdb 100644 (file)
@@ -719,7 +719,8 @@ make_new_block (struct function *fn, unsigned int index)
 /* Read the CFG for function FN from input block IB.  */
 
 static void
-input_cfg (struct lto_input_block *ib, struct function *fn)
+input_cfg (struct lto_input_block *ib, struct function *fn,
+          int count_materialization_scale)
 {
   unsigned int bb_count;
   basic_block p_bb;
@@ -766,7 +767,8 @@ input_cfg (struct lto_input_block *ib, struct function *fn)
 
          dest_index = lto_input_uleb128 (ib);
          probability = (int) lto_input_sleb128 (ib);
-         count = (gcov_type) lto_input_sleb128 (ib);
+         count = ((gcov_type) lto_input_sleb128 (ib) * count_materialization_scale
+                  + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
          edge_flags = lto_input_uleb128 (ib);
 
          dest = BASIC_BLOCK_FOR_FUNCTION (fn, dest_index);
@@ -1066,7 +1068,8 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
 
 static void
 input_bb (struct lto_input_block *ib, enum LTO_tags tag,
-         struct data_in *data_in, struct function *fn)
+         struct data_in *data_in, struct function *fn,
+         int count_materialization_scale)
 {
   unsigned int index;
   basic_block bb;
@@ -1079,7 +1082,8 @@ input_bb (struct lto_input_block *ib, enum LTO_tags tag,
   index = lto_input_uleb128 (ib);
   bb = BASIC_BLOCK_FOR_FUNCTION (fn, index);
 
-  bb->count = lto_input_sleb128 (ib);
+  bb->count = (lto_input_sleb128 (ib) * count_materialization_scale
+              + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
   bb->loop_depth = lto_input_sleb128 (ib);
   bb->frequency = lto_input_sleb128 (ib);
   bb->flags = lto_input_sleb128 (ib);
@@ -1253,12 +1257,14 @@ input_function (tree fn_decl, struct data_in *data_in,
   DECL_INITIAL (fn_decl) = lto_input_tree (ib, data_in);
   gcc_assert (DECL_INITIAL (fn_decl));
   DECL_SAVED_TREE (fn_decl) = NULL_TREE;
+  node = cgraph_node (fn_decl);
 
   /* Read all the basic blocks.  */
   tag = input_record_start (ib);
   while (tag)
     {
-      input_bb (ib, tag, data_in, fn);
+      input_bb (ib, tag, data_in, fn,
+               node->count_materialization_scale);
       tag = input_record_start (ib);
     }
 
@@ -1300,7 +1306,6 @@ input_function (tree fn_decl, struct data_in *data_in,
     gimple_set_body (fn_decl, bb_seq (ei_edge (ei)->dest));
   }
 
-  node = cgraph_node (fn_decl);
   fixup_call_stmt_edges (node, stmts);
   execute_all_ipa_stmt_fixups (node, stmts);
 
@@ -1393,6 +1398,7 @@ lto_read_body (struct lto_file_decl_data *file_data, tree fn_decl,
     {
       struct function *fn = DECL_STRUCT_FUNCTION (fn_decl);
       struct lto_in_decl_state *decl_state;
+      struct cgraph_node *node = cgraph_node (fn_decl);
 
       push_cfun (fn);
       init_tree_ssa (fn);
@@ -1402,7 +1408,7 @@ lto_read_body (struct lto_file_decl_data *file_data, tree fn_decl,
       gcc_assert (decl_state);
       file_data->current_decl_state = decl_state;
 
-      input_cfg (&ib_cfg, fn);
+      input_cfg (&ib_cfg, fn, node->count_materialization_scale);
 
       /* Set up the struct function.  */
       input_function (fn_decl, data_in, &ib_main);