From 5ce8d99a1b45692a14b4a8aaf5b481738bf95172 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Mon, 16 Nov 2015 12:40:24 +0000 Subject: [PATCH] Remove first_pass_instance from pass_dominator 2015-11-16 Tom de Vries * passes.def: Add arg to pass_dominator pass instantiation. * tree-pass.h (first_pass_instance): Remove pass_dominator-related bit of comment. * tree-ssa-dom.c (pass_dominator::pass_dominator): Initialize may_peel_loop_headers_p. (pass_dominator::set_pass_param): New member function. Set may_peel_loop_headers_p. (pass_dominator::may_peel_loop_headers_p): New private member. (pass_dominator::execute): Use may_peel_loop_headers_p instead of first_pass_instance. From-SVN: r230417 --- gcc/ChangeLog | 13 +++++++++++++ gcc/passes.def | 4 ++-- gcc/tree-pass.h | 7 ++----- gcc/tree-ssa-dom.c | 16 ++++++++++++++-- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 91bfc8c9a95..3ab8e652ced 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2015-11-16 Tom de Vries + + * passes.def: Add arg to pass_dominator pass instantiation. + * tree-pass.h (first_pass_instance): Remove pass_dominator-related bit + of comment. + * tree-ssa-dom.c (pass_dominator::pass_dominator): Initialize + may_peel_loop_headers_p. + (pass_dominator::set_pass_param): New member function. Set + may_peel_loop_headers_p. + (pass_dominator::may_peel_loop_headers_p): New private member. + (pass_dominator::execute): Use may_peel_loop_headers_p instead of + first_pass_instance. + 2015-11-16 Tom de Vries * passes.def: Add arg to pass_reassoc pass instantiation. diff --git a/gcc/passes.def b/gcc/passes.def index 78fdf0ffc5d..d274a950d9b 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -190,7 +190,7 @@ along with GCC; see the file COPYING3. If not see propagations have already run, but before some more dead code is removed, and this place fits nicely. Remember this when trying to move or duplicate pass_dominator somewhere earlier. */ - NEXT_PASS (pass_dominator); + NEXT_PASS (pass_dominator, true /* may_peel_loop_headers_p */); /* At this point the majority of const/copy propagations are exposed. Go ahead and identify paths that should never be executed in a conforming program and isolate those paths. @@ -279,7 +279,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_reassoc, false /* insert_powi_p */); NEXT_PASS (pass_strength_reduction); NEXT_PASS (pass_tracer); - NEXT_PASS (pass_dominator); + NEXT_PASS (pass_dominator, false /* may_peel_loop_headers_p */); NEXT_PASS (pass_strlen); NEXT_PASS (pass_vrp, false /* warn_array_bounds_p */); /* The only const/copy propagation opportunities left after diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index a672d528b03..d647e730a3e 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -631,11 +631,8 @@ extern bool function_called_by_processed_nodes_p (void); /* Set to true if the pass is called the first time during compilation of the current function. Note that using this information in the optimization - passes is considered not to be clean, and it should be avoided if possible. - This flag is currently used to prevent loops from being peeled repeatedly - in jump threading; it will be removed once we preserve loop structures - throughout the compilation -- we will be able to mark the affected loops - directly in jump threading, and avoid peeling them next time. */ + passes is considered not to be clean, and it should be avoided if + possible. */ extern bool first_pass_instance; /* Declare for plugins. */ diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 5cb26441b51..aeb726c9bdb 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -536,14 +536,26 @@ class pass_dominator : public gimple_opt_pass { public: pass_dominator (gcc::context *ctxt) - : gimple_opt_pass (pass_data_dominator, ctxt) + : gimple_opt_pass (pass_data_dominator, ctxt), + may_peel_loop_headers_p (false) {} /* opt_pass methods: */ opt_pass * clone () { return new pass_dominator (m_ctxt); } + void set_pass_param (unsigned int n, bool param) + { + gcc_assert (n == 0); + may_peel_loop_headers_p = param; + } virtual bool gate (function *) { return flag_tree_dom != 0; } virtual unsigned int execute (function *); + private: + /* This flag is used to prevent loops from being peeled repeatedly in jump + threading; it will be removed once we preserve loop structures throughout + the compilation -- we will be able to mark the affected loops directly in + jump threading, and avoid peeling them next time. */ + bool may_peel_loop_headers_p; }; // class pass_dominator unsigned int @@ -619,7 +631,7 @@ pass_dominator::execute (function *fun) free_all_edge_infos (); /* Thread jumps, creating duplicate blocks as needed. */ - cfg_altered |= thread_through_all_blocks (first_pass_instance); + cfg_altered |= thread_through_all_blocks (may_peel_loop_headers_p); if (cfg_altered) free_dominance_info (CDI_DOMINATORS); -- 2.30.2