Commit d37d06fe by Diego Novillo Committed by Diego Novillo

re PR tree-optimization/30562 (remove unused variable is removing a referenced…

re PR tree-optimization/30562 (remove unused variable is removing a referenced variable (in STORED_SYMS or LOADED_SYMS))


	PR 30562
	* tree-flow.h (struct var_ann_d): Remove field 'is_used'.
	Update all users.
	* tree-ssa-alias.c (compute_is_aliased): Remove.  Update all
	users.
	(init_alias_info):
	* tree-ssa-live.c (remove_unused_locals): Do not remove
	TREE_ADDRESSABLE variables.
	* tree-ssa-structalias.c (compute_points_to_sets): Tidy.
	* tree-ssa-operands.c (add_virtual_operand): Remove argument
	FOR_CLOBBER.  Update all users.
	If VAR has an associated alias set, add a virtual operand for
	it if no alias is found to conflict with the memory reference.

From-SVN: r121715
parent e35a0e64
2007-02-08 Diego Novillo <dnovillo@redhat.com>
PR 30562
* tree-flow.h (struct var_ann_d): Remove field 'is_used'.
Update all users.
* tree-ssa-alias.c (compute_is_aliased): Remove. Update all
users.
(init_alias_info):
* tree-ssa-live.c (remove_unused_locals): Do not remove
TREE_ADDRESSABLE variables.
* tree-ssa-structalias.c (compute_points_to_sets): Tidy.
* tree-ssa-operands.c (add_virtual_operand): Remove argument
FOR_CLOBBER. Update all users.
If VAR has an associated alias set, add a virtual operand for
it if no alias is found to conflict with the memory reference.
2007-02-07 Jan Hubicka <jh@suse.cz> 2007-02-07 Jan Hubicka <jh@suse.cz>
Robert Kidd <rkidd@crhc.uiuc.edu> Robert Kidd <rkidd@crhc.uiuc.edu>
......
...@@ -337,9 +337,6 @@ dump_variable (FILE *file, tree var) ...@@ -337,9 +337,6 @@ dump_variable (FILE *file, tree var)
print_generic_expr (file, ann->symbol_mem_tag, dump_flags); print_generic_expr (file, ann->symbol_mem_tag, dump_flags);
} }
if (ann && ann->is_aliased)
fprintf (file, ", is aliased");
if (TREE_ADDRESSABLE (var)) if (TREE_ADDRESSABLE (var))
fprintf (file, ", is addressable"); fprintf (file, ", is addressable");
......
...@@ -228,9 +228,6 @@ struct var_ann_d GTY(()) ...@@ -228,9 +228,6 @@ struct var_ann_d GTY(())
/* Used when building base variable structures in a var_map. */ /* Used when building base variable structures in a var_map. */
unsigned base_var_processed : 1; unsigned base_var_processed : 1;
/* Nonzero if this variable is in the alias set of another variable. */
unsigned is_aliased : 1;
/* Nonzero if this variable was used after SSA optimizations were /* Nonzero if this variable was used after SSA optimizations were
applied. We set this when translating out of SSA form. */ applied. We set this when translating out of SSA form. */
unsigned used : 1; unsigned used : 1;
......
...@@ -776,43 +776,6 @@ done: ...@@ -776,43 +776,6 @@ done:
timevar_pop (TV_MEMORY_PARTITIONING); timevar_pop (TV_MEMORY_PARTITIONING);
} }
/* This function computes the value of the is_aliased bit for
variables. is_aliased is true for any variable that is in an
alias bitmap. */
static void
compute_is_aliased (void)
{
referenced_var_iterator rvi;
tree tag;
bitmap aliased_vars = BITMAP_ALLOC (NULL);
bitmap_iterator bi;
unsigned int i;
/* Add is_aliased for all vars pointed to by the symbol tags. */
FOR_EACH_REFERENCED_VAR (tag, rvi)
{
bitmap aliases;
if (TREE_CODE (tag) != SYMBOL_MEMORY_TAG
&& TREE_CODE (tag) != NAME_MEMORY_TAG)
continue;
aliases = MTAG_ALIASES (tag);
if (!aliases)
continue;
bitmap_ior_into (aliased_vars, aliases);
}
EXECUTE_IF_SET_IN_BITMAP (aliased_vars, 0, i, bi)
{
tree var = referenced_var (i);
var_ann (var)->is_aliased = true;
}
BITMAP_FREE (aliased_vars);
}
/* Compute may-alias information for every variable referenced in function /* Compute may-alias information for every variable referenced in function
FNDECL. FNDECL.
...@@ -980,9 +943,6 @@ compute_may_aliases (void) ...@@ -980,9 +943,6 @@ compute_may_aliases (void)
dump_points_to_info (dump_file); dump_points_to_info (dump_file);
dump_alias_info (dump_file); dump_alias_info (dump_file);
} }
/* Set up is_aliased flags. */
compute_is_aliased ();
/* Deallocate memory used by aliasing data structures. */ /* Deallocate memory used by aliasing data structures. */
delete_alias_info (ai); delete_alias_info (ai);
...@@ -1170,10 +1130,6 @@ init_alias_info (void) ...@@ -1170,10 +1130,6 @@ init_alias_info (void)
/* Clear flow-insensitive alias information from each symbol. */ /* Clear flow-insensitive alias information from each symbol. */
FOR_EACH_REFERENCED_VAR (var, rvi) FOR_EACH_REFERENCED_VAR (var, rvi)
{ {
var_ann_t ann = var_ann (var);
ann->is_aliased = 0;
if (MTAG_P (var)) if (MTAG_P (var))
MTAG_ALIASES (var) = NULL; MTAG_ALIASES (var) = NULL;
......
...@@ -502,18 +502,20 @@ remove_unused_locals (void) ...@@ -502,18 +502,20 @@ remove_unused_locals (void)
cell = &TREE_CHAIN (*cell); cell = &TREE_CHAIN (*cell);
} }
/* Remove unused variables from REFERENCED_VARs. As an special exception /* Remove unused variables from REFERENCED_VARs. As a special
keep the variables that are believed to be aliased. Those can't be exception keep the variables that are believed to be aliased.
easily removed from the alias sets and and operand caches. Those can't be easily removed from the alias sets and operand
They will be removed shortly after next may_alias pass is performed. */ caches. They will be removed shortly after the next may_alias
pass is performed. */
FOR_EACH_REFERENCED_VAR (t, rvi) FOR_EACH_REFERENCED_VAR (t, rvi)
if (!is_global_var (t) if (!is_global_var (t)
&& !MTAG_P (t) && !MTAG_P (t)
&& TREE_CODE (t) != PARM_DECL && TREE_CODE (t) != PARM_DECL
&& TREE_CODE (t) != RESULT_DECL && TREE_CODE (t) != RESULT_DECL
&& !(ann = var_ann (t))->used && !(ann = var_ann (t))->used
&& !ann->is_aliased && !is_call_clobbered (t) && !ann->symbol_mem_tag) && !ann->symbol_mem_tag
remove_referenced_var (t); && !TREE_ADDRESSABLE (t))
remove_referenced_var (t);
} }
......
...@@ -1433,13 +1433,12 @@ access_can_touch_variable (tree ref, tree alias, HOST_WIDE_INT offset, ...@@ -1433,13 +1433,12 @@ access_can_touch_variable (tree ref, tree alias, HOST_WIDE_INT offset,
get_expr_operands. FULL_REF is a tree that contains the entire get_expr_operands. FULL_REF is a tree that contains the entire
pointer dereference expression, if available, or NULL otherwise. pointer dereference expression, if available, or NULL otherwise.
OFFSET and SIZE come from the memory access expression that OFFSET and SIZE come from the memory access expression that
generated this virtual operand. FOR_CLOBBER is true is this is generated this virtual operand. */
adding a virtual operand for a call clobber. */
static void static void
add_virtual_operand (tree var, stmt_ann_t s_ann, int flags, add_virtual_operand (tree var, stmt_ann_t s_ann, int flags,
tree full_ref, HOST_WIDE_INT offset, tree full_ref, HOST_WIDE_INT offset,
HOST_WIDE_INT size, bool for_clobber) HOST_WIDE_INT size)
{ {
bitmap aliases = NULL; bitmap aliases = NULL;
tree sym; tree sym;
...@@ -1514,24 +1513,13 @@ add_virtual_operand (tree var, stmt_ann_t s_ann, int flags, ...@@ -1514,24 +1513,13 @@ add_virtual_operand (tree var, stmt_ann_t s_ann, int flags,
append_vdef (al); append_vdef (al);
} }
/* If the variable is also an alias tag, add a virtual /* Even if no aliases have been added, we still need to
operand for it, otherwise we will miss representing establish def-use and use-def chains, lest
references to the members of the variable's alias set. transformations think that this is not a memory
This fixes the bug in gcc.c-torture/execute/20020503-1.c. reference. For an example of this scenario, see
testsuite/g++.dg/opt/cleanup1.C. */
It is also necessary to add bare defs on clobbers for if (none_added)
SMT's, so that bare SMT uses caused by pruning all the append_vdef (var);
aliases will link up properly with calls. In order to
keep the number of these bare defs we add down to the
minimum necessary, we keep track of which SMT's were used
alone in statement vdefs or VUSEs. */
if (v_ann->is_aliased
|| none_added
|| (TREE_CODE (var) == SYMBOL_MEMORY_TAG
&& for_clobber))
{
append_vdef (var);
}
} }
else else
{ {
...@@ -1545,9 +1533,12 @@ add_virtual_operand (tree var, stmt_ann_t s_ann, int flags, ...@@ -1545,9 +1533,12 @@ add_virtual_operand (tree var, stmt_ann_t s_ann, int flags,
append_vuse (al); append_vuse (al);
} }
/* Similarly, append a virtual uses for VAR itself, when /* Even if no aliases have been added, we still need to
it is an alias tag. */ establish def-use and use-def chains, lest
if (v_ann->is_aliased || none_added) transformations think that this is not a memory
reference. For an example of this scenario, see
testsuite/g++.dg/opt/cleanup1.C. */
if (none_added)
append_vuse (var); append_vuse (var);
} }
} }
...@@ -1584,7 +1575,7 @@ add_stmt_operand (tree *var_p, stmt_ann_t s_ann, int flags) ...@@ -1584,7 +1575,7 @@ add_stmt_operand (tree *var_p, stmt_ann_t s_ann, int flags)
append_use (var_p); append_use (var_p);
} }
else else
add_virtual_operand (var, s_ann, flags, NULL_TREE, 0, -1, false); add_virtual_operand (var, s_ann, flags, NULL_TREE, 0, -1);
} }
...@@ -1631,7 +1622,7 @@ get_indirect_ref_operands (tree stmt, tree expr, int flags, ...@@ -1631,7 +1622,7 @@ get_indirect_ref_operands (tree stmt, tree expr, int flags,
{ {
/* PTR has its own memory tag. Use it. */ /* PTR has its own memory tag. Use it. */
add_virtual_operand (pi->name_mem_tag, s_ann, flags, add_virtual_operand (pi->name_mem_tag, s_ann, flags,
full_ref, offset, size, false); full_ref, offset, size);
} }
else else
{ {
...@@ -1660,7 +1651,7 @@ get_indirect_ref_operands (tree stmt, tree expr, int flags, ...@@ -1660,7 +1651,7 @@ get_indirect_ref_operands (tree stmt, tree expr, int flags,
if (v_ann->symbol_mem_tag) if (v_ann->symbol_mem_tag)
add_virtual_operand (v_ann->symbol_mem_tag, s_ann, flags, add_virtual_operand (v_ann->symbol_mem_tag, s_ann, flags,
full_ref, offset, size, false); full_ref, offset, size);
/* Aliasing information is missing; mark statement as volatile so we /* Aliasing information is missing; mark statement as volatile so we
won't optimize it out too actively. */ won't optimize it out too actively. */
else if (s_ann && !gimple_aliases_computed_p (cfun) else if (s_ann && !gimple_aliases_computed_p (cfun)
...@@ -1818,7 +1809,7 @@ add_call_clobber_ops (tree stmt, tree callee) ...@@ -1818,7 +1809,7 @@ add_call_clobber_ops (tree stmt, tree callee)
clobber_stats.static_read_clobbers_avoided++; clobber_stats.static_read_clobbers_avoided++;
} }
else else
add_virtual_operand (var, s_ann, opf_def, NULL, 0, -1, true); add_virtual_operand (var, s_ann, opf_def, NULL, 0, -1);
} }
} }
......
...@@ -4663,6 +4663,7 @@ compute_points_to_sets (struct alias_info *ai) ...@@ -4663,6 +4663,7 @@ compute_points_to_sets (struct alias_info *ai)
if (is_gimple_reg (PHI_RESULT (phi))) if (is_gimple_reg (PHI_RESULT (phi)))
{ {
find_func_aliases (phi); find_func_aliases (phi);
/* Update various related attributes like escaped /* Update various related attributes like escaped
addresses, pointer dereferences for loads and stores. addresses, pointer dereferences for loads and stores.
This is used when creating name tags and alias This is used when creating name tags and alias
......
...@@ -375,7 +375,6 @@ static void ...@@ -375,7 +375,6 @@ static void
verify_flow_insensitive_alias_info (void) verify_flow_insensitive_alias_info (void)
{ {
tree var; tree var;
bitmap visited = BITMAP_ALLOC (NULL);
referenced_var_iterator rvi; referenced_var_iterator rvi;
FOR_EACH_REFERENCED_VAR (var, rvi) FOR_EACH_REFERENCED_VAR (var, rvi)
...@@ -393,7 +392,6 @@ verify_flow_insensitive_alias_info (void) ...@@ -393,7 +392,6 @@ verify_flow_insensitive_alias_info (void)
EXECUTE_IF_SET_IN_BITMAP (aliases, 0, j, bi) EXECUTE_IF_SET_IN_BITMAP (aliases, 0, j, bi)
{ {
alias = referenced_var (j); alias = referenced_var (j);
bitmap_set_bit (visited, j);
if (TREE_CODE (alias) != MEMORY_PARTITION_TAG if (TREE_CODE (alias) != MEMORY_PARTITION_TAG
&& !may_be_aliased (alias)) && !may_be_aliased (alias))
...@@ -405,23 +403,6 @@ verify_flow_insensitive_alias_info (void) ...@@ -405,23 +403,6 @@ verify_flow_insensitive_alias_info (void)
} }
} }
FOR_EACH_REFERENCED_VAR (var, rvi)
{
var_ann_t ann;
ann = var_ann (var);
if (!MTAG_P (var)
&& ann->is_aliased
&& memory_partition (var) == NULL_TREE
&& !bitmap_bit_p (visited, DECL_UID (var)))
{
error ("addressable variable that is aliased but is not in any "
"alias set");
goto err;
}
}
BITMAP_FREE (visited);
return; return;
err: err:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment