aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/tree-dfa.c23
-rw-r--r--gcc/tree-flow.h1
-rw-r--r--gcc/tree-ssa-live.c25
4 files changed, 48 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e79b7de..b5addb8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2007-01-14 Jan Hubicka <jh@suse.cz>
+ * tree-dfa.c (remove_referenced_var): New function.
+ * tree-ssa-live.c (remove_unused_locals): Walk referenced vars and
+ prune referenced vars list too.
+ * tree-flow.h (remove_referenced_var): Declare.
+
+2007-01-14 Jan Hubicka <jh@suse.cz>
+
* tree-eh.c (add_stmt_to_eh_region_fn): Do not add call_exprs
separately.
(remove_stmt_from_eh_region_fn): Do not remove call_exprs.
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index 59899f1..93c58f78 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -752,6 +752,29 @@ add_referenced_var (tree var)
}
}
+/* Remove VAR from the list. */
+
+void
+remove_referenced_var (tree var)
+{
+ var_ann_t v_ann;
+ struct int_tree_map in;
+ void **loc;
+ unsigned int uid = DECL_UID (var);
+
+ clear_call_clobbered (var);
+ v_ann = get_var_ann (var);
+ ggc_free (v_ann);
+ var->base.ann = NULL;
+ gcc_assert (DECL_P (var));
+ in.uid = uid;
+ in.to = var;
+ loc = htab_find_slot_with_hash (gimple_referenced_vars (cfun), &in, uid,
+ NO_INSERT);
+ ggc_free (*loc);
+ htab_clear_slot (gimple_referenced_vars (cfun), loc);
+}
+
/* Return the virtual variable associated to the non-scalar variable VAR. */
diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index 5bd07dc..0b029ee 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -698,6 +698,7 @@ extern void dump_subvars_for (FILE *, tree);
extern void debug_subvars_for (tree);
extern tree get_virtual_var (tree);
extern void add_referenced_var (tree);
+extern void remove_referenced_var (tree);
extern void mark_symbols_for_renaming (tree);
extern void find_new_referenced_vars (tree *);
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index eecf6e7..cc4972f 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -449,15 +449,12 @@ remove_unused_locals (void)
{
basic_block bb;
tree t, *cell;
+ referenced_var_iterator rvi;
+ var_ann_t ann;
/* 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;
- }
+ FOR_EACH_REFERENCED_VAR (t, rvi)
+ var_ann (t)->used = false;
/* Walk the CFG marking all referenced symbols. */
FOR_EACH_BB (bb)
@@ -493,7 +490,6 @@ remove_unused_locals (void)
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))
@@ -505,6 +501,19 @@ remove_unused_locals (void)
cell = &TREE_CHAIN (*cell);
}
+
+ /* Remove unused variables from REFERENCED_VARs. As an special exception
+ keep the variables that are believed to be aliased. Those can't be
+ easilly removed from the alias sets and and operand caches.
+ They will be removed shortly after next may_alias pass is performed. */
+ FOR_EACH_REFERENCED_VAR (t, rvi)
+ if (!is_global_var (t)
+ && !MTAG_P (t)
+ && TREE_CODE (t) != PARM_DECL
+ && TREE_CODE (t) != RESULT_DECL
+ && !(ann = var_ann (t))->used
+ && !ann->is_aliased && !is_call_clobbered (t) && !ann->symbol_mem_tag)
+ remove_referenced_var (t);
}