aboutsummaryrefslogtreecommitdiff
path: root/gcc/predict.c
diff options
context:
space:
mode:
authorTrevor Saunders <tsaunders@mozilla.com>2014-04-17 12:37:34 +0000
committerTrevor Saunders <tbsaunde@gcc.gnu.org>2014-04-17 12:37:34 +0000
commitbe55bfe6cf456943b12fe128f8a445b583ace36f (patch)
tree2c7de59d1f6572c580defbe0ccac2d0b83cd1eb3 /gcc/predict.c
parent1a3d085cf2a0caa5daef7c0443b1d280bcef295e (diff)
downloadgcc-be55bfe6cf456943b12fe128f8a445b583ace36f.zip
gcc-be55bfe6cf456943b12fe128f8a445b583ace36f.tar.gz
gcc-be55bfe6cf456943b12fe128f8a445b583ace36f.tar.bz2
pass cfun to pass::execute
gcc/ * passes.c (opt_pass::execute): Adjust. (pass_manager::execute_pass_mode_switching): Likewise. (early_local_passes::execute): Likewise. (execute_one_pass): Pass cfun to the pass's execute method. * tree-pass.h (opt_pass::execute): Add function * argument. * asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c, cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c, compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c, config/epiphany/resolve-sw-modes.c, config/i386/i386.c, config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c, config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c, except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c, gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c, graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c, ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c, ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c, lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c, postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c, reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c, store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c, tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c, tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c, tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c, tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c, tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c, tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c, tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c, tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c, tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c, tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c, tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c, tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c, tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c, tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c: Adjust. From-SVN: r209482
Diffstat (limited to 'gcc/predict.c')
-rw-r--r--gcc/predict.c170
1 files changed, 84 insertions, 86 deletions
diff --git a/gcc/predict.c b/gcc/predict.c
index 068c187..a847ec6 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -1986,59 +1986,6 @@ expr_expected_value (tree expr, bitmap visited,
return expr_expected_value_1 (TREE_TYPE (expr),
op0, code, op1, visited, predictor);
}
-
-
-/* Get rid of all builtin_expect calls and GIMPLE_PREDICT statements
- we no longer need. */
-static unsigned int
-strip_predict_hints (void)
-{
- basic_block bb;
- gimple ass_stmt;
- tree var;
-
- FOR_EACH_BB_FN (bb, cfun)
- {
- gimple_stmt_iterator bi;
- for (bi = gsi_start_bb (bb); !gsi_end_p (bi);)
- {
- gimple stmt = gsi_stmt (bi);
-
- if (gimple_code (stmt) == GIMPLE_PREDICT)
- {
- gsi_remove (&bi, true);
- continue;
- }
- else if (is_gimple_call (stmt))
- {
- tree fndecl = gimple_call_fndecl (stmt);
-
- if ((fndecl
- && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
- && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT
- && gimple_call_num_args (stmt) == 2)
- || (gimple_call_internal_p (stmt)
- && gimple_call_internal_fn (stmt) == IFN_BUILTIN_EXPECT))
- {
- var = gimple_call_lhs (stmt);
- if (var)
- {
- ass_stmt
- = gimple_build_assign (var, gimple_call_arg (stmt, 0));
- gsi_replace (&bi, ass_stmt, true);
- }
- else
- {
- gsi_remove (&bi, true);
- continue;
- }
- }
- }
- gsi_next (&bi);
- }
- }
- return 0;
-}
/* Predict using opcode of the last statement in basic block. */
static void
@@ -2468,37 +2415,6 @@ tree_estimate_probability (void)
free_dominance_info (CDI_POST_DOMINATORS);
remove_fake_exit_edges ();
}
-
-/* Predict branch probabilities and estimate profile of the tree CFG.
- This is the driver function for PASS_PROFILE. */
-
-static unsigned int
-tree_estimate_probability_driver (void)
-{
- unsigned nb_loops;
-
- loop_optimizer_init (LOOPS_NORMAL);
- if (dump_file && (dump_flags & TDF_DETAILS))
- flow_loops_dump (dump_file, NULL, 0);
-
- mark_irreducible_loops ();
-
- nb_loops = number_of_loops (cfun);
- if (nb_loops > 1)
- scev_initialize ();
-
- tree_estimate_probability ();
-
- if (nb_loops > 1)
- scev_finalize ();
-
- loop_optimizer_finalize ();
- if (dump_file && (dump_flags & TDF_DETAILS))
- gimple_dump_cfg (dump_file, dump_flags);
- if (profile_status_for_fn (cfun) == PROFILE_ABSENT)
- profile_status_for_fn (cfun) = PROFILE_GUESSED;
- return 0;
-}
/* Predict edges to successors of CUR whose sources are not postdominated by
BB by PRED and recurse to all postdominators. */
@@ -3147,6 +3063,8 @@ predictor_name (enum br_predictor predictor)
return predictor_info[predictor].name;
}
+/* Predict branch probabilities and estimate profile of the tree CFG. */
+
namespace {
const pass_data pass_data_profile =
@@ -3172,10 +3090,38 @@ public:
/* opt_pass methods: */
virtual bool gate (function *) { return flag_guess_branch_prob; }
- unsigned int execute () { return tree_estimate_probability_driver (); }
+ virtual unsigned int execute (function *);
}; // class pass_profile
+unsigned int
+pass_profile::execute (function *fun)
+{
+ unsigned nb_loops;
+
+ loop_optimizer_init (LOOPS_NORMAL);
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ flow_loops_dump (dump_file, NULL, 0);
+
+ mark_irreducible_loops ();
+
+ nb_loops = number_of_loops (fun);
+ if (nb_loops > 1)
+ scev_initialize ();
+
+ tree_estimate_probability ();
+
+ if (nb_loops > 1)
+ scev_finalize ();
+
+ loop_optimizer_finalize ();
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ gimple_dump_cfg (dump_file, dump_flags);
+ if (profile_status_for_fn (fun) == PROFILE_ABSENT)
+ profile_status_for_fn (fun) = PROFILE_GUESSED;
+ return 0;
+}
+
} // anon namespace
gimple_opt_pass *
@@ -3209,10 +3155,62 @@ public:
/* opt_pass methods: */
opt_pass * clone () { return new pass_strip_predict_hints (m_ctxt); }
- unsigned int execute () { return strip_predict_hints (); }
+ virtual unsigned int execute (function *);
}; // class pass_strip_predict_hints
+/* Get rid of all builtin_expect calls and GIMPLE_PREDICT statements
+ we no longer need. */
+unsigned int
+pass_strip_predict_hints::execute (function *fun)
+{
+ basic_block bb;
+ gimple ass_stmt;
+ tree var;
+
+ FOR_EACH_BB_FN (bb, fun)
+ {
+ gimple_stmt_iterator bi;
+ for (bi = gsi_start_bb (bb); !gsi_end_p (bi);)
+ {
+ gimple stmt = gsi_stmt (bi);
+
+ if (gimple_code (stmt) == GIMPLE_PREDICT)
+ {
+ gsi_remove (&bi, true);
+ continue;
+ }
+ else if (is_gimple_call (stmt))
+ {
+ tree fndecl = gimple_call_fndecl (stmt);
+
+ if ((fndecl
+ && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
+ && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT
+ && gimple_call_num_args (stmt) == 2)
+ || (gimple_call_internal_p (stmt)
+ && gimple_call_internal_fn (stmt) == IFN_BUILTIN_EXPECT))
+ {
+ var = gimple_call_lhs (stmt);
+ if (var)
+ {
+ ass_stmt
+ = gimple_build_assign (var, gimple_call_arg (stmt, 0));
+ gsi_replace (&bi, ass_stmt, true);
+ }
+ else
+ {
+ gsi_remove (&bi, true);
+ continue;
+ }
+ }
+ }
+ gsi_next (&bi);
+ }
+ }
+ return 0;
+}
+
} // anon namespace
gimple_opt_pass *