aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Pinski <quic_apinski@quicinc.com>2024-10-13 11:16:51 -0700
committerAndrew Pinski <quic_apinski@quicinc.com>2024-10-14 07:34:53 -0700
commit60de5585812f59a3095fa6208b01ddb8382634a0 (patch)
tree12e53f8363493fec90109ae9b13219f506158b05 /gcc
parent0110a381de6b843c0d7dcb7fcd563a678a763ddb (diff)
downloadgcc-60de5585812f59a3095fa6208b01ddb8382634a0.zip
gcc-60de5585812f59a3095fa6208b01ddb8382634a0.tar.gz
gcc-60de5585812f59a3095fa6208b01ddb8382634a0.tar.bz2
dce: add remove_unused_locals conditionally to the todos [PR117096]
This is the updated patch with the suggestion from: https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665217.html Where we use a second arg/param to set which passes we want to have the remove_unused_locals on the dce. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: PR tree-optimization/117096 * passes.def: Update some of the dce/cd-cde passes setting the 2nd arg to true. Also remove comment about stdarg since dce does it. * tree-ssa-dce.cc (pass_dce): Add remove_unused_locals_p field. Update set_pass_param to allow for 2nd param. Use remove_unused_locals_p in execute to return TODO_remove_unused_locals. (pass_cd_dce): Likewise. * tree-stdarg.cc (pass_data_stdarg): Remove TODO_remove_unused_locals. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/passes.def11
-rw-r--r--gcc/tree-ssa-dce.cc18
-rw-r--r--gcc/tree-stdarg.cc2
3 files changed, 19 insertions, 12 deletions
diff --git a/gcc/passes.def b/gcc/passes.def
index 40162ac..7d01227 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 69249c7..66612b5 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 1167fd9..33763cd 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 */
};