diff options
author | Diego Novillo <dnovillo@google.com> | 2007-08-15 13:37:33 -0400 |
---|---|---|
committer | Diego Novillo <dnovillo@gcc.gnu.org> | 2007-08-15 13:37:33 -0400 |
commit | bbe984fb21c228ea077bcb4bcde6376bb45a4899 (patch) | |
tree | fd79a84b87f517fe99964e6f19729cf28e159637 /gcc/tree-ssa-alias.c | |
parent | b413c535af276684074dee54eb322168f52689a8 (diff) | |
download | gcc-bbe984fb21c228ea077bcb4bcde6376bb45a4899.zip gcc-bbe984fb21c228ea077bcb4bcde6376bb45a4899.tar.gz gcc-bbe984fb21c228ea077bcb4bcde6376bb45a4899.tar.bz2 |
tree-ssa-alias.c (compute_memory_partitions): Use alias_bitmap_obstack to allocate bitmaps.
* tree-ssa-alias.c (compute_memory_partitions): Use
alias_bitmap_obstack to allocate bitmaps.
(reset_alias_info): Factor out of init_alias_info.
Mark all name tags not associated to an SSA name for renaming.
(init_alias_info): Call it.
(create_name_tags): Tidy. Add comments.
(dump_points_to_info_for): Do not call get_mem_sym_stats_for.
testsuite/ChangeLog
gcc.dg/tree-ssa/20070815.c: New test.
From-SVN: r127520
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r-- | gcc/tree-ssa-alias.c | 172 |
1 files changed, 103 insertions, 69 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 3889ea5..3a490fc 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -1497,7 +1497,7 @@ compute_memory_partitions (void) virtual operands. However, by reducing the size of the alias sets to be scanned, the work needed inside the operand scanner is significantly reduced. */ - new_aliases = BITMAP_ALLOC (NULL); + new_aliases = BITMAP_ALLOC (&alias_bitmap_obstack); for (i = 0; VEC_iterate (tree, tags, i, tag); i++) { @@ -1891,6 +1891,103 @@ init_mem_ref_stats (void) } +/* Helper for init_alias_info. Reset existing aliasing information. */ + +static void +reset_alias_info (void) +{ + referenced_var_iterator rvi; + tree var; + unsigned i; + bitmap active_nmts, all_nmts; + + /* Clear the set of addressable variables. We do not need to clear + the TREE_ADDRESSABLE bit on every symbol because we are going to + re-compute addressability here. */ + bitmap_clear (gimple_addressable_vars (cfun)); + + active_nmts = BITMAP_ALLOC (&alias_bitmap_obstack); + all_nmts = BITMAP_ALLOC (&alias_bitmap_obstack); + + /* Clear flow-insensitive alias information from each symbol. */ + FOR_EACH_REFERENCED_VAR (var, rvi) + { + if (is_gimple_reg (var)) + continue; + + if (MTAG_P (var)) + MTAG_ALIASES (var) = NULL; + + /* Memory partition information will be computed from scratch. */ + if (TREE_CODE (var) == MEMORY_PARTITION_TAG) + MPT_SYMBOLS (var) = NULL; + + /* Collect all the name tags to determine if we have any + orphaned that need to be removed from the IL. A name tag + will be orphaned if it is not associated with any active SSA + name. */ + if (TREE_CODE (var) == NAME_MEMORY_TAG) + bitmap_set_bit (all_nmts, DECL_UID (var)); + + /* Since we are about to re-discover call-clobbered + variables, clear the call-clobbered flag. Variables that + are intrinsically call-clobbered (globals, local statics, + etc) will not be marked by the aliasing code, so we can't + remove them from CALL_CLOBBERED_VARS. + + NB: STRUCT_FIELDS are still call clobbered if they are for a + global variable, so we *don't* clear their call clobberedness + just because they are tags, though we will clear it if they + aren't for global variables. */ + if (TREE_CODE (var) == NAME_MEMORY_TAG + || TREE_CODE (var) == SYMBOL_MEMORY_TAG + || TREE_CODE (var) == MEMORY_PARTITION_TAG + || !is_global_var (var)) + clear_call_clobbered (var); + } + + /* Clear flow-sensitive points-to information from each SSA name. */ + for (i = 1; i < num_ssa_names; i++) + { + tree name = ssa_name (i); + + if (!name || !POINTER_TYPE_P (TREE_TYPE (name))) + continue; + + if (SSA_NAME_PTR_INFO (name)) + { + struct ptr_info_def *pi = SSA_NAME_PTR_INFO (name); + + /* Clear all the flags but keep the name tag to + avoid creating new temporaries unnecessarily. If + this pointer is found to point to a subset or + superset of its former points-to set, then a new + tag will need to be created in create_name_tags. */ + pi->pt_anything = 0; + pi->pt_null = 0; + pi->value_escapes_p = 0; + pi->is_dereferenced = 0; + if (pi->pt_vars) + bitmap_clear (pi->pt_vars); + + /* Add NAME's name tag to the set of active tags. */ + if (pi->name_mem_tag) + bitmap_set_bit (active_nmts, DECL_UID (pi->name_mem_tag)); + } + } + + /* Name memory tags that are no longer associated with an SSA name + are considered stale and should be removed from the IL. All the + name tags that are in the set ALL_NMTS but not in ACTIVE_NMTS are + considered stale and marked for renaming. */ + bitmap_and_compl_into (all_nmts, active_nmts); + mark_set_for_renaming (all_nmts); + + BITMAP_FREE (all_nmts); + BITMAP_FREE (active_nmts); +} + + /* Initialize the data structures used for alias analysis. */ static struct alias_info * @@ -1913,70 +2010,7 @@ init_alias_info (void) /* If aliases have been computed before, clear existing information. */ if (gimple_aliases_computed_p (cfun)) - { - unsigned i; - - /* Similarly, clear the set of addressable variables. In this - case, we can just clear the set because addressability is - only computed here. */ - bitmap_clear (gimple_addressable_vars (cfun)); - - /* Clear flow-insensitive alias information from each symbol. */ - FOR_EACH_REFERENCED_VAR (var, rvi) - { - if (is_gimple_reg (var)) - continue; - - if (MTAG_P (var)) - MTAG_ALIASES (var) = NULL; - - /* Memory partition information will be computed from scratch. */ - if (TREE_CODE (var) == MEMORY_PARTITION_TAG) - MPT_SYMBOLS (var) = NULL; - - /* Since we are about to re-discover call-clobbered - variables, clear the call-clobbered flag. Variables that - are intrinsically call-clobbered (globals, local statics, - etc) will not be marked by the aliasing code, so we can't - remove them from CALL_CLOBBERED_VARS. - - NB: STRUCT_FIELDS are still call clobbered if they are - for a global variable, so we *don't* clear their call - clobberedness just because they are tags, though we will - clear it if they aren't for global variables. */ - if (TREE_CODE (var) == NAME_MEMORY_TAG - || TREE_CODE (var) == SYMBOL_MEMORY_TAG - || TREE_CODE (var) == MEMORY_PARTITION_TAG - || !is_global_var (var)) - clear_call_clobbered (var); - } - - /* Clear flow-sensitive points-to information from each SSA name. */ - for (i = 1; i < num_ssa_names; i++) - { - tree name = ssa_name (i); - - if (!name || !POINTER_TYPE_P (TREE_TYPE (name))) - continue; - - if (SSA_NAME_PTR_INFO (name)) - { - struct ptr_info_def *pi = SSA_NAME_PTR_INFO (name); - - /* Clear all the flags but keep the name tag to - avoid creating new temporaries unnecessarily. If - this pointer is found to point to a subset or - superset of its former points-to set, then a new - tag will need to be created in create_name_tags. */ - pi->pt_anything = 0; - pi->pt_null = 0; - pi->value_escapes_p = 0; - pi->is_dereferenced = 0; - if (pi->pt_vars) - bitmap_clear (pi->pt_vars); - } - } - } + reset_alias_info (); else { /* If this is the first time we compute aliasing information, @@ -2123,6 +2157,7 @@ create_name_tags (void) else { *slot = pi; + /* If we didn't find a pointer with the same points-to set as PTR, create a new name tag if needed. */ if (pi->name_mem_tag == NULL_TREE) @@ -2135,7 +2170,8 @@ create_name_tags (void) renaming. */ if (old_name_tag && old_name_tag != pi->name_mem_tag) mark_sym_for_renaming (old_name_tag); - + + /* Inherit volatility from the pointed-to type. */ TREE_THIS_VOLATILE (pi->name_mem_tag) |= TREE_THIS_VOLATILE (TREE_TYPE (TREE_TYPE (ptr))); @@ -3215,9 +3251,7 @@ dump_points_to_info_for (FILE *file, tree ptr) } if (pi->is_dereferenced) - fprintf (file, ", is dereferenced (R=%ld, W=%ld)", - get_mem_sym_stats_for (ptr)->num_direct_reads, - get_mem_sym_stats_for (ptr)->num_direct_writes); + fprintf (file, ", is dereferenced"); if (pi->value_escapes_p) fprintf (file, ", its value escapes"); |