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
This commit is contained in:
parent
e35a0e6476
commit
d37d06fef8
8 changed files with 44 additions and 103 deletions
|
@ -1,3 +1,19 @@
|
|||
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>
|
||||
Robert Kidd <rkidd@crhc.uiuc.edu>
|
||||
|
||||
|
|
|
@ -337,9 +337,6 @@ dump_variable (FILE *file, tree var)
|
|||
print_generic_expr (file, ann->symbol_mem_tag, dump_flags);
|
||||
}
|
||||
|
||||
if (ann && ann->is_aliased)
|
||||
fprintf (file, ", is aliased");
|
||||
|
||||
if (TREE_ADDRESSABLE (var))
|
||||
fprintf (file, ", is addressable");
|
||||
|
||||
|
|
|
@ -228,9 +228,6 @@ struct var_ann_d GTY(())
|
|||
/* Used when building base variable structures in a var_map. */
|
||||
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
|
||||
applied. We set this when translating out of SSA form. */
|
||||
unsigned used : 1;
|
||||
|
|
|
@ -776,43 +776,6 @@ done:
|
|||
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
|
||||
FNDECL.
|
||||
|
@ -980,9 +943,6 @@ compute_may_aliases (void)
|
|||
dump_points_to_info (dump_file);
|
||||
dump_alias_info (dump_file);
|
||||
}
|
||||
|
||||
/* Set up is_aliased flags. */
|
||||
compute_is_aliased ();
|
||||
|
||||
/* Deallocate memory used by aliasing data structures. */
|
||||
delete_alias_info (ai);
|
||||
|
@ -1170,10 +1130,6 @@ init_alias_info (void)
|
|||
/* Clear flow-insensitive alias information from each symbol. */
|
||||
FOR_EACH_REFERENCED_VAR (var, rvi)
|
||||
{
|
||||
var_ann_t ann = var_ann (var);
|
||||
|
||||
ann->is_aliased = 0;
|
||||
|
||||
if (MTAG_P (var))
|
||||
MTAG_ALIASES (var) = NULL;
|
||||
|
||||
|
|
|
@ -502,18 +502,20 @@ 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
|
||||
easily removed from the alias sets and and operand caches.
|
||||
They will be removed shortly after next may_alias pass is performed. */
|
||||
/* Remove unused variables from REFERENCED_VARs. As a special
|
||||
exception keep the variables that are believed to be aliased.
|
||||
Those can't be easily removed from the alias sets and operand
|
||||
caches. They will be removed shortly after the 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);
|
||||
&& !ann->symbol_mem_tag
|
||||
&& !TREE_ADDRESSABLE (t))
|
||||
remove_referenced_var (t);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
pointer dereference expression, if available, or NULL otherwise.
|
||||
OFFSET and SIZE come from the memory access expression that
|
||||
generated this virtual operand. FOR_CLOBBER is true is this is
|
||||
adding a virtual operand for a call clobber. */
|
||||
generated this virtual operand. */
|
||||
|
||||
static void
|
||||
add_virtual_operand (tree var, stmt_ann_t s_ann, int flags,
|
||||
tree full_ref, HOST_WIDE_INT offset,
|
||||
HOST_WIDE_INT size, bool for_clobber)
|
||||
HOST_WIDE_INT size)
|
||||
{
|
||||
bitmap aliases = NULL;
|
||||
tree sym;
|
||||
|
@ -1514,24 +1513,13 @@ add_virtual_operand (tree var, stmt_ann_t s_ann, int flags,
|
|||
append_vdef (al);
|
||||
}
|
||||
|
||||
/* If the variable is also an alias tag, add a virtual
|
||||
operand for it, otherwise we will miss representing
|
||||
references to the members of the variable's alias set.
|
||||
This fixes the bug in gcc.c-torture/execute/20020503-1.c.
|
||||
|
||||
It is also necessary to add bare defs on clobbers for
|
||||
SMT's, so that bare SMT uses caused by pruning all the
|
||||
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);
|
||||
}
|
||||
/* Even if no aliases have been added, we still need to
|
||||
establish def-use and use-def chains, lest
|
||||
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_vdef (var);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1545,9 +1533,12 @@ add_virtual_operand (tree var, stmt_ann_t s_ann, int flags,
|
|||
append_vuse (al);
|
||||
}
|
||||
|
||||
/* Similarly, append a virtual uses for VAR itself, when
|
||||
it is an alias tag. */
|
||||
if (v_ann->is_aliased || none_added)
|
||||
/* Even if no aliases have been added, we still need to
|
||||
establish def-use and use-def chains, lest
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1584,7 +1575,7 @@ add_stmt_operand (tree *var_p, stmt_ann_t s_ann, int flags)
|
|||
append_use (var_p);
|
||||
}
|
||||
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,
|
|||
{
|
||||
/* PTR has its own memory tag. Use it. */
|
||||
add_virtual_operand (pi->name_mem_tag, s_ann, flags,
|
||||
full_ref, offset, size, false);
|
||||
full_ref, offset, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1660,7 +1651,7 @@ get_indirect_ref_operands (tree stmt, tree expr, int flags,
|
|||
|
||||
if (v_ann->symbol_mem_tag)
|
||||
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
|
||||
won't optimize it out too actively. */
|
||||
else if (s_ann && !gimple_aliases_computed_p (cfun)
|
||||
|
@ -1818,7 +1809,7 @@ add_call_clobber_ops (tree stmt, tree callee)
|
|||
clobber_stats.static_read_clobbers_avoided++;
|
||||
}
|
||||
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)
|
|||
if (is_gimple_reg (PHI_RESULT (phi)))
|
||||
{
|
||||
find_func_aliases (phi);
|
||||
|
||||
/* Update various related attributes like escaped
|
||||
addresses, pointer dereferences for loads and stores.
|
||||
This is used when creating name tags and alias
|
||||
|
|
|
@ -375,7 +375,6 @@ static void
|
|||
verify_flow_insensitive_alias_info (void)
|
||||
{
|
||||
tree var;
|
||||
bitmap visited = BITMAP_ALLOC (NULL);
|
||||
referenced_var_iterator rvi;
|
||||
|
||||
FOR_EACH_REFERENCED_VAR (var, rvi)
|
||||
|
@ -393,7 +392,6 @@ verify_flow_insensitive_alias_info (void)
|
|||
EXECUTE_IF_SET_IN_BITMAP (aliases, 0, j, bi)
|
||||
{
|
||||
alias = referenced_var (j);
|
||||
bitmap_set_bit (visited, j);
|
||||
|
||||
if (TREE_CODE (alias) != MEMORY_PARTITION_TAG
|
||||
&& !may_be_aliased (alias))
|
||||
|
@ -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;
|
||||
|
||||
err:
|
||||
|
|
Loading…
Add table
Reference in a new issue