summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-live.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-05 13:53:54 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-05 13:53:54 +0000
commitdb22d3cc2fb885dec7aea38a58ee7775d93d7dd1 (patch)
tree6cf1f63c9110bc738fd2520546f623d74c55ebb4 /gcc/tree-ssa-live.c
parent30afe54504cdc744a64e0473bdb27995c07d76d4 (diff)
downloadgcc-db22d3cc2fb885dec7aea38a58ee7775d93d7dd1.tar.gz
2006-01-05 Richard Guenther <rguenther@suse.de>
Diego Novillo <dnovillo@redhat.com> * tree-pass.h (TODO_remove_unused_locals): Define. * gimple-low.c (expand_var_p, remove_useless_vars, pass_remove_useless_vars): Remove. Update all users. * tree-ssa-live.c (mark_all_vars_used_1): Handle SSA names. (remove_unused_locals): New function. * tree-flow.h (remove_unused_locals): Declare. * passes.c (execute_todo): Call remove_unused_locals if TODO_remove_unused_locals is set. * tree-into-ssa.c (pass_build_ssa): Add TODO_remove_unused_locals. * tree-ssa-dce.c (pass_dce): Likewise. * tree-outof-ssa.c (pass_del_ssa): Likewise. * gcc.dg/tree-ssa/loop-11.c: Deal with removed vars pass. * gcc.dg/tree-ssa/loop-8.c: Likewise. * gcc.dg/tree-ssa/loop-1.c: Likewise. * gcc.dg/tree-ssa/pr23294.c: Likewise. * gcc.dg/tree-ssa/pr21985.c: Likewise. * gcc.dg/tree-ssa/loop-14.c: Likewise. * gcc.dg/tree-ssa/loop-2.c: Likewise. * gcc.dg/tree-ssa/loop-3.c: Likewise. * gcc.dg/tree-ssa/loop-4.c: Likewise. * gcc.dg/tree-ssa/pr21171.c: Likewise. * gcc.dg/tree-ssa/loop-5.c: Likewise. * gcc.dg/tree-ssa/loop-10.c: Likewise. * gcc.dg/tree-ssa/loop-6.c: Likewise. * treelang/compile/extravar.tree: Likewise. * g++.dg/tree-ssa/ssa-cast-1.C: Likewise. * g++.dg/tree-ssa/pointer-reference-alias.C: Likewise. * g++.dg/tree-ssa/ssa-sra-1.C: Likewise. * g++.dg/tree-ssa/ssa-sra-2.C: Likewise. * gcc.dg/tree-ssa/20031106-6.c: Disable SRA. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109379 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-live.c')
-rw-r--r--gcc/tree-ssa-live.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 8c02a2b4b66..e011a5d250c 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -296,6 +296,9 @@ mark_all_vars_used_1 (tree *tp, int *walk_subtrees,
{
tree t = *tp;
+ if (TREE_CODE (t) == SSA_NAME)
+ t = SSA_NAME_VAR (t);
+
/* Ignore TREE_ORIGINAL for TARGET_MEM_REFS, as well as other
fields that do not contain vars. */
if (TREE_CODE (t) == TARGET_MEM_REF)
@@ -327,6 +330,72 @@ mark_all_vars_used (tree *expr_p)
walk_tree (expr_p, mark_all_vars_used_1, NULL, NULL);
}
+
+/* Remove local variables that are not referenced in the IL. */
+
+void
+remove_unused_locals (void)
+{
+ basic_block bb;
+ tree t, *cell;
+
+ /* Assume all locals are unused. */
+ for (t = cfun->unexpanded_var_list; t; t = TREE_CHAIN (t))
+ {
+ tree var = TREE_VALUE (t);
+ if (TREE_CODE (var) != FUNCTION_DECL
+ && var_ann (var))
+ var_ann (var)->used = false;
+ }
+
+ /* Walk the CFG marking all referenced symbols. */
+ FOR_EACH_BB (bb)
+ {
+ block_stmt_iterator bsi;
+ tree phi, def;
+
+ /* Walk the statements. */
+ for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
+ mark_all_vars_used (bsi_stmt_ptr (bsi));
+
+ for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
+ {
+ use_operand_p arg_p;
+ ssa_op_iter i;
+
+ /* No point processing globals. */
+ if (is_global_var (SSA_NAME_VAR (PHI_RESULT (phi))))
+ continue;
+
+ def = PHI_RESULT (phi);
+ mark_all_vars_used (&def);
+
+ FOR_EACH_PHI_ARG (arg_p, phi, i, SSA_OP_ALL_USES)
+ {
+ tree arg = USE_FROM_PTR (arg_p);
+ mark_all_vars_used (&arg);
+ }
+ }
+ }
+
+ /* Remove unmarked vars and clear used flag. */
+ for (cell = &cfun->unexpanded_var_list; *cell; )
+ {
+ tree var = TREE_VALUE (*cell);
+ var_ann_t ann;
+
+ if (TREE_CODE (var) != FUNCTION_DECL
+ && (!(ann = var_ann (var))
+ || !ann->used))
+ {
+ *cell = TREE_CHAIN (*cell);
+ continue;
+ }
+
+ cell = &TREE_CHAIN (*cell);
+ }
+}
+
/* This function looks through the program and uses FLAGS to determine what
SSA versioned variables are given entries in a new partition table. This
new partition map is returned. */
@@ -362,6 +431,7 @@ create_ssa_var_map (int flags)
FOR_EACH_BB (bb)
{
tree phi, arg;
+
for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
{
int i;