@@ -85,6 +85,8 @@ static void delete_dead_or_redundant_call (gimple_stmt_iterator *, const char *)
remove their dead edges eventually. */
static bitmap need_eh_cleanup;
+static unsigned n_stores_removed;
+
/* STMT is a statement that may write into memory. Analyze it and
initialize WRITE to describe how STMT affects memory.
@@ -1031,6 +1033,8 @@ delete_dead_or_redundant_assignment (gimple_stmt_iterator *gsi, const char *type
/* And release any SSA_NAMEs set in this statement back to the
SSA_NAME manager. */
release_defs (stmt);
+
+ n_stores_removed++;
}
/* Attempt to eliminate dead stores in the statement referenced by BSI.
@@ -1222,6 +1226,7 @@ unsigned int
pass_dse::execute (function *fun)
{
need_eh_cleanup = BITMAP_ALLOC (NULL);
+ n_stores_removed = 0;
renumber_gimple_stmt_uids (cfun);
@@ -1236,6 +1241,9 @@ pass_dse::execute (function *fun)
tree and a backwards walk of statements within each block. */
dse_dom_walker (CDI_POST_DOMINATORS).walk (fun->cfg->x_exit_block_ptr);
+ /* Wipe the post-dominator information. */
+ free_dominance_info (CDI_POST_DOMINATORS);
+
/* Removal of stores may make some EH edges dead. Purge such edges from
the CFG as needed. */
if (!bitmap_empty_p (need_eh_cleanup))
@@ -1246,9 +1254,9 @@ pass_dse::execute (function *fun)
BITMAP_FREE (need_eh_cleanup);
- /* For now, just wipe the post-dominator information. */
- free_dominance_info (CDI_POST_DOMINATORS);
- return 0;
+ /* If we elided a store try to get rid of unused locals and in
+ particular stray CLOBBERs of otherwise unused variables. */
+ return n_stores_removed != 0 ? TODO_remove_unused_locals : 0;
}
} // anon namespace