diff options
Diffstat (limited to 'gcc/profile.c')
| -rw-r--r-- | gcc/profile.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/gcc/profile.c b/gcc/profile.c index c32003e787c..054f0771f47 100644 --- a/gcc/profile.c +++ b/gcc/profile.c @@ -65,6 +65,9 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "tree.h" #include "cfghooks.h" #include "tree-flow.h" +#include "timevar.h" +#include "cfgloop.h" +#include "tree-pass.h" /* Hooks for profiling. */ static struct profile_hooks* profile_hooks; @@ -1329,3 +1332,78 @@ rtl_register_profile_hooks (void) gcc_assert (!ir_type ()); profile_hooks = &rtl_profile_hooks; } + +static bool +gate_handle_profiling (void) +{ + return optimize > 0 + || (!flag_tree_based_profiling + && (profile_arc_flag || flag_test_coverage + || flag_branch_probabilities)); +} + +struct tree_opt_pass pass_profiling = +{ + NULL, /* name */ + gate_handle_profiling, /* gate */ + NULL, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + 0, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ + 0 /* letter */ +}; + + +/* Do branch profiling and static profile estimation passes. */ +static void +rest_of_handle_branch_prob (void) +{ + struct loops loops; + + rtl_register_profile_hooks (); + rtl_register_value_prof_hooks (); + + if ((profile_arc_flag || flag_test_coverage || flag_branch_probabilities) + && !flag_tree_based_profiling) + branch_prob (); + + /* Discover and record the loop depth at the head of each basic + block. The loop infrastructure does the real job for us. */ + flow_loops_find (&loops); + + if (dump_file) + flow_loops_dump (&loops, dump_file, NULL, 0); + + /* Estimate using heuristics if no profiling info is available. */ + if (flag_guess_branch_prob && profile_status == PROFILE_ABSENT) + estimate_probability (&loops); + + flow_loops_free (&loops); + free_dominance_info (CDI_DOMINATORS); +} + +struct tree_opt_pass pass_branch_prob = +{ + "bp", /* name */ + NULL, /* gate */ + rest_of_handle_branch_prob, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + TV_BRANCH_PROB, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_dump_func, /* todo_flags_finish */ + 'b' /* letter */ +}; + + + |

