aboutsummaryrefslogtreecommitdiff
path: root/gcc/bb-reorder.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/bb-reorder.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/bb-reorder.c')
-rw-r--r--gcc/bb-reorder.c231
1 files changed, 115 insertions, 116 deletions
diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index 57103bd..db490f1 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -2302,26 +2302,6 @@ insert_section_boundary_note (void)
}
}
-static unsigned int
-rest_of_handle_reorder_blocks (void)
-{
- basic_block bb;
-
- /* Last attempt to optimize CFG, as scheduling, peepholing and insn
- splitting possibly introduced more crossjumping opportunities. */
- cfg_layout_initialize (CLEANUP_EXPENSIVE);
-
- reorder_basic_blocks ();
- cleanup_cfg (CLEANUP_EXPENSIVE);
-
- FOR_EACH_BB_FN (bb, cfun)
- if (bb->next_bb != EXIT_BLOCK_PTR_FOR_FN (cfun))
- bb->aux = bb->next_bb;
- cfg_layout_finalize ();
-
- return 0;
-}
-
namespace {
const pass_data pass_data_reorder_blocks =
@@ -2354,10 +2334,30 @@ public:
&& (flag_reorder_blocks || flag_reorder_blocks_and_partition));
}
- unsigned int execute () { return rest_of_handle_reorder_blocks (); }
+ virtual unsigned int execute (function *);
}; // class pass_reorder_blocks
+unsigned int
+pass_reorder_blocks::execute (function *fun)
+{
+ basic_block bb;
+
+ /* Last attempt to optimize CFG, as scheduling, peepholing and insn
+ splitting possibly introduced more crossjumping opportunities. */
+ cfg_layout_initialize (CLEANUP_EXPENSIVE);
+
+ reorder_basic_blocks ();
+ cleanup_cfg (CLEANUP_EXPENSIVE);
+
+ FOR_EACH_BB_FN (bb, fun)
+ if (bb->next_bb != EXIT_BLOCK_PTR_FOR_FN (fun))
+ bb->aux = bb->next_bb;
+ cfg_layout_finalize ();
+
+ return 0;
+}
+
} // anon namespace
rtl_opt_pass *
@@ -2372,16 +2372,54 @@ make_pass_reorder_blocks (gcc::context *ctxt)
which can seriously pessimize code with many computed jumps in the source
code, such as interpreters. See e.g. PR15242. */
+namespace {
-static unsigned int
-duplicate_computed_gotos (void)
+const pass_data pass_data_duplicate_computed_gotos =
+{
+ RTL_PASS, /* type */
+ "compgotos", /* name */
+ OPTGROUP_NONE, /* optinfo_flags */
+ true, /* has_execute */
+ TV_REORDER_BLOCKS, /* tv_id */
+ 0, /* properties_required */
+ 0, /* properties_provided */
+ 0, /* properties_destroyed */
+ 0, /* todo_flags_start */
+ TODO_verify_rtl_sharing, /* todo_flags_finish */
+};
+
+class pass_duplicate_computed_gotos : public rtl_opt_pass
+{
+public:
+ pass_duplicate_computed_gotos (gcc::context *ctxt)
+ : rtl_opt_pass (pass_data_duplicate_computed_gotos, ctxt)
+ {}
+
+ /* opt_pass methods: */
+ virtual bool gate (function *);
+ virtual unsigned int execute (function *);
+
+}; // class pass_duplicate_computed_gotos
+
+bool
+pass_duplicate_computed_gotos::gate (function *fun)
+{
+ if (targetm.cannot_modify_jumps_p ())
+ return false;
+ return (optimize > 0
+ && flag_expensive_optimizations
+ && ! optimize_function_for_size_p (fun));
+}
+
+unsigned int
+pass_duplicate_computed_gotos::execute (function *fun)
{
basic_block bb, new_bb;
bitmap candidates;
int max_size;
bool changed = false;
- if (n_basic_blocks_for_fn (cfun) <= NUM_FIXED_BLOCKS + 1)
+ if (n_basic_blocks_for_fn (fun) <= NUM_FIXED_BLOCKS + 1)
return 0;
clear_bb_flags ();
@@ -2400,7 +2438,7 @@ duplicate_computed_gotos (void)
/* Look for blocks that end in a computed jump, and see if such blocks
are suitable for unfactoring. If a block is a candidate for unfactoring,
mark it in the candidates. */
- FOR_EACH_BB_FN (bb, cfun)
+ FOR_EACH_BB_FN (bb, fun)
{
rtx insn;
edge e;
@@ -2408,7 +2446,7 @@ duplicate_computed_gotos (void)
int size, all_flags;
/* Build the reorder chain for the original order of blocks. */
- if (bb->next_bb != EXIT_BLOCK_PTR_FOR_FN (cfun))
+ if (bb->next_bb != EXIT_BLOCK_PTR_FOR_FN (fun))
bb->aux = bb->next_bb;
/* Obviously the block has to end in a computed jump. */
@@ -2447,7 +2485,7 @@ duplicate_computed_gotos (void)
goto done;
/* Duplicate computed gotos. */
- FOR_EACH_BB_FN (bb, cfun)
+ FOR_EACH_BB_FN (bb, fun)
{
if (bb->flags & BB_VISITED)
continue;
@@ -2458,7 +2496,7 @@ duplicate_computed_gotos (void)
the exit block or the next block.
The destination must have more than one predecessor. */
if (!single_succ_p (bb)
- || single_succ (bb) == EXIT_BLOCK_PTR_FOR_FN (cfun)
+ || single_succ (bb) == EXIT_BLOCK_PTR_FOR_FN (fun)
|| single_succ (bb) == bb->next_bb
|| single_pred_p (single_succ (bb)))
continue;
@@ -2491,45 +2529,6 @@ done:
return 0;
}
-namespace {
-
-const pass_data pass_data_duplicate_computed_gotos =
-{
- RTL_PASS, /* type */
- "compgotos", /* name */
- OPTGROUP_NONE, /* optinfo_flags */
- true, /* has_execute */
- TV_REORDER_BLOCKS, /* tv_id */
- 0, /* properties_required */
- 0, /* properties_provided */
- 0, /* properties_destroyed */
- 0, /* todo_flags_start */
- TODO_verify_rtl_sharing, /* todo_flags_finish */
-};
-
-class pass_duplicate_computed_gotos : public rtl_opt_pass
-{
-public:
- pass_duplicate_computed_gotos (gcc::context *ctxt)
- : rtl_opt_pass (pass_data_duplicate_computed_gotos, ctxt)
- {}
-
- /* opt_pass methods: */
- virtual bool gate (function *);
- unsigned int execute () { return duplicate_computed_gotos (); }
-
-}; // class pass_duplicate_computed_gotos
-
-bool
-pass_duplicate_computed_gotos::gate (function *fun)
-{
- if (targetm.cannot_modify_jumps_p ())
- return false;
- return (optimize > 0
- && flag_expensive_optimizations
- && ! optimize_function_for_size_p (fun));
-}
-
} // anon namespace
rtl_opt_pass *
@@ -2627,12 +2626,57 @@ make_pass_duplicate_computed_gotos (gcc::context *ctxt)
Unconditional branches are dealt with by converting them into
indirect jumps. */
-static unsigned
-partition_hot_cold_basic_blocks (void)
+namespace {
+
+const pass_data pass_data_partition_blocks =
+{
+ RTL_PASS, /* type */
+ "bbpart", /* name */
+ OPTGROUP_NONE, /* optinfo_flags */
+ true, /* has_execute */
+ TV_REORDER_BLOCKS, /* tv_id */
+ PROP_cfglayout, /* properties_required */
+ 0, /* properties_provided */
+ 0, /* properties_destroyed */
+ 0, /* todo_flags_start */
+ 0, /* todo_flags_finish */
+};
+
+class pass_partition_blocks : public rtl_opt_pass
+{
+public:
+ pass_partition_blocks (gcc::context *ctxt)
+ : rtl_opt_pass (pass_data_partition_blocks, ctxt)
+ {}
+
+ /* opt_pass methods: */
+ virtual bool gate (function *);
+ virtual unsigned int execute (function *);
+
+}; // class pass_partition_blocks
+
+bool
+pass_partition_blocks::gate (function *fun)
+{
+ /* The optimization to partition hot/cold basic blocks into separate
+ sections of the .o file does not work well with linkonce or with
+ user defined section attributes. Don't call it if either case
+ arises. */
+ return (flag_reorder_blocks_and_partition
+ && optimize
+ /* See gate_handle_reorder_blocks. We should not partition if
+ we are going to omit the reordering. */
+ && optimize_function_for_speed_p (fun)
+ && !DECL_ONE_ONLY (current_function_decl)
+ && !user_defined_section_attribute);
+}
+
+unsigned
+pass_partition_blocks::execute (function *fun)
{
vec<edge> crossing_edges;
- if (n_basic_blocks_for_fn (cfun) <= NUM_FIXED_BLOCKS + 1)
+ if (n_basic_blocks_for_fn (fun) <= NUM_FIXED_BLOCKS + 1)
return 0;
df_set_flags (DF_DEFER_INSN_RESCAN);
@@ -2693,7 +2737,7 @@ partition_hot_cold_basic_blocks (void)
In the meantime, we have no other option but to throw away all
of the DF data and recompute it all. */
- if (cfun->eh->lp_array)
+ if (fun->eh->lp_array)
{
df_finish_pass (true);
df_scan_alloc (NULL);
@@ -2708,51 +2752,6 @@ partition_hot_cold_basic_blocks (void)
return TODO_verify_flow | TODO_verify_rtl_sharing;
}
-namespace {
-
-const pass_data pass_data_partition_blocks =
-{
- RTL_PASS, /* type */
- "bbpart", /* name */
- OPTGROUP_NONE, /* optinfo_flags */
- true, /* has_execute */
- TV_REORDER_BLOCKS, /* tv_id */
- PROP_cfglayout, /* properties_required */
- 0, /* properties_provided */
- 0, /* properties_destroyed */
- 0, /* todo_flags_start */
- 0, /* todo_flags_finish */
-};
-
-class pass_partition_blocks : public rtl_opt_pass
-{
-public:
- pass_partition_blocks (gcc::context *ctxt)
- : rtl_opt_pass (pass_data_partition_blocks, ctxt)
- {}
-
- /* opt_pass methods: */
- virtual bool gate (function *);
- unsigned int execute () { return partition_hot_cold_basic_blocks (); }
-
-}; // class pass_partition_blocks
-
-bool
-pass_partition_blocks::gate (function *fun)
-{
- /* The optimization to partition hot/cold basic blocks into separate
- sections of the .o file does not work well with linkonce or with
- user defined section attributes. Don't call it if either case
- arises. */
- return (flag_reorder_blocks_and_partition
- && optimize
- /* See gate_handle_reorder_blocks. We should not partition if
- we are going to omit the reordering. */
- && optimize_function_for_speed_p (fun)
- && !DECL_ONE_ONLY (current_function_decl)
- && !user_defined_section_attribute);
-}
-
} // anon namespace
rtl_opt_pass *