diff --git a/gcc/passes.def b/gcc/passes.def index 40162ac20a0..7d01227eed1 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -92,7 +92,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_early_vrp); NEXT_PASS (pass_merge_phi); NEXT_PASS (pass_dse); - NEXT_PASS (pass_cd_dce, false /* update_address_taken_p */); + NEXT_PASS (pass_cd_dce, false /* update_address_taken_p */, true /* remove_unused_locals */); NEXT_PASS (pass_phiopt, true /* early_p */); NEXT_PASS (pass_tail_recursion); NEXT_PASS (pass_if_to_switch); @@ -225,10 +225,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_vrp, false /* final_p*/); NEXT_PASS (pass_array_bounds); NEXT_PASS (pass_dse); - NEXT_PASS (pass_dce); - /* pass_stdarg is always run and at this point we execute - TODO_remove_unused_locals to prune CLOBBERs of dead - variables which are otherwise a churn on alias walkings. */ + NEXT_PASS (pass_dce, false /* update_address_taken_p */, true /* remove_unused_locals */); NEXT_PASS (pass_stdarg); NEXT_PASS (pass_call_cdce); NEXT_PASS (pass_cselim); @@ -273,7 +270,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_asan); NEXT_PASS (pass_tsan); NEXT_PASS (pass_dse, true /* use DR analysis */); - NEXT_PASS (pass_dce); + NEXT_PASS (pass_dce, false /* update_address_taken_p */, false /* remove_unused_locals */); /* Pass group that runs when 1) enabled, 2) there are loops in the function. Make sure to run pass_fix_loops before to discover/remove loops before running the gate function @@ -355,7 +352,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_ccp, true /* nonzero_p */); NEXT_PASS (pass_warn_restrict); NEXT_PASS (pass_dse); - NEXT_PASS (pass_dce, true /* update_address_taken_p */); + NEXT_PASS (pass_dce, true /* update_address_taken_p */, true /* remove_unused_locals */); /* After late DCE we rewrite no longer addressed locals into SSA form if possible. */ NEXT_PASS (pass_forwprop); diff --git a/gcc/tree-ssa-dce.cc b/gcc/tree-ssa-dce.cc index 69249c73013..66612b5d575 100644 --- a/gcc/tree-ssa-dce.cc +++ b/gcc/tree-ssa-dce.cc @@ -2096,18 +2096,23 @@ public: opt_pass * clone () final override { return new pass_dce (m_ctxt); } void set_pass_param (unsigned n, bool param) final override { - gcc_assert (n == 0); - update_address_taken_p = param; + gcc_assert (n == 0 || n == 1); + if (n == 0) + update_address_taken_p = param; + else if (n == 1) + remove_unused_locals_p = param; } bool gate (function *) final override { return flag_tree_dce != 0; } unsigned int execute (function *) final override { return (tree_ssa_dce () + | (remove_unused_locals_p ? TODO_remove_unused_locals : 0) | (update_address_taken_p ? TODO_update_address_taken : 0)); } private: bool update_address_taken_p; + bool remove_unused_locals_p = false; }; // class pass_dce } // anon namespace @@ -2144,18 +2149,23 @@ public: opt_pass * clone () final override { return new pass_cd_dce (m_ctxt); } void set_pass_param (unsigned n, bool param) final override { - gcc_assert (n == 0); - update_address_taken_p = param; + gcc_assert (n == 0 || n == 1); + if (n == 0) + update_address_taken_p = param; + else if (n == 1) + remove_unused_locals_p = param; } bool gate (function *) final override { return flag_tree_dce != 0; } unsigned int execute (function *) final override { return (tree_ssa_cd_dce () + | (remove_unused_locals_p ? TODO_remove_unused_locals : 0) | (update_address_taken_p ? TODO_update_address_taken : 0)); } private: bool update_address_taken_p; + bool remove_unused_locals_p = false; }; // class pass_cd_dce } // anon namespace diff --git a/gcc/tree-stdarg.cc b/gcc/tree-stdarg.cc index 1167fd9f224..33763cd3d11 100644 --- a/gcc/tree-stdarg.cc +++ b/gcc/tree-stdarg.cc @@ -1114,7 +1114,7 @@ const pass_data pass_data_stdarg = ( PROP_cfg | PROP_ssa ), /* properties_required */ PROP_gimple_lva, /* properties_provided */ 0, /* properties_destroyed */ - TODO_remove_unused_locals, /* todo_flags_start */ + 0, /* todo_flags_start */ 0, /* todo_flags_finish */ };