+ gcov_type count_scale;
+ edge e;
+ edge_iterator ei;
+
+ if (ENTRY_BLOCK_PTR->count)
+ count_scale = ((cgraph_get_node (current_function_decl)->count
+ * REG_BR_PROB_BASE + ENTRY_BLOCK_PTR->count / 2)
+ / ENTRY_BLOCK_PTR->count);
+ else
+ count_scale = REG_BR_PROB_BASE;
+
+ ENTRY_BLOCK_PTR->count = cgraph_get_node (current_function_decl)->count;
+ EXIT_BLOCK_PTR->count = (EXIT_BLOCK_PTR->count * count_scale
+ + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
+
+ FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
+ e->count = (e->count * count_scale
+ + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
+
+ FOR_EACH_BB (bb)
+ {
+ bb->count = (bb->count * count_scale
+ + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
+ for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ {
+ gimple stmt = gsi_stmt (gsi);
+ tree decl = is_gimple_call (stmt)
+ ? gimple_call_fndecl (stmt)
+ : NULL;
+ if (decl)
+ {
+ int flags = gimple_call_flags (stmt);
+ if (flags & (ECF_CONST | ECF_PURE | ECF_LOOPING_CONST_OR_PURE))
+ {
+ if (gimple_purge_dead_abnormal_call_edges (bb))
+ todo |= TODO_cleanup_cfg;
+
+ if (gimple_in_ssa_p (cfun))
+ {
+ todo |= TODO_update_ssa | TODO_cleanup_cfg;
+ update_stmt (stmt);
+ }
+ }
+
+ if (flags & ECF_NORETURN
+ && fixup_noreturn_call (stmt))
+ todo |= TODO_cleanup_cfg;
+ }
+
+ if (maybe_clean_eh_stmt (stmt)
+ && gimple_purge_dead_eh_edges (bb))
+ todo |= TODO_cleanup_cfg;
+ }
+
+ FOR_EACH_EDGE (e, ei, bb->succs)
+ e->count = (e->count * count_scale
+ + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
+ }
+ if (count_scale != REG_BR_PROB_BASE)
+ compute_function_frequency ();