diff options
Diffstat (limited to 'gcc/tree-ssa-coalesce.c')
-rw-r--r-- | gcc/tree-ssa-coalesce.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c index 388437d..a96029a 100644 --- a/gcc/tree-ssa-coalesce.c +++ b/gcc/tree-ssa-coalesce.c @@ -1297,6 +1297,24 @@ coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl, } } +/* Returns a hash code for P. */ + +static hashval_t +hash_ssa_name_by_var (const void *p) +{ + const_tree n = (const_tree) p; + return (hashval_t) htab_hash_pointer (SSA_NAME_VAR (n)); +} + +/* Returns nonzero if P1 and P2 are equal. */ + +static int +eq_ssa_name_by_var (const void *p1, const void *p2) +{ + const_tree n1 = (const_tree) p1; + const_tree n2 = (const_tree) p2; + return SSA_NAME_VAR (n1) == SSA_NAME_VAR (n2); +} /* Reduce the number of copies by coalescing variables in the function. Return a partition map with the resulting coalesces. */ @@ -1310,10 +1328,42 @@ coalesce_ssa_name (void) coalesce_list_p cl; bitmap used_in_copies = BITMAP_ALLOC (NULL); var_map map; + unsigned int i; + static htab_t ssa_name_hash; cl = create_coalesce_list (); map = create_outofssa_var_map (cl, used_in_copies); + /* We need to coalesce all names originating same SSA_NAME_VAR + so debug info remains undisturbed. */ + if (!optimize) + { + ssa_name_hash = htab_create (10, hash_ssa_name_by_var, + eq_ssa_name_by_var, NULL); + for (i = 1; i < num_ssa_names; i++) + { + tree a = ssa_name (i); + + if (a && SSA_NAME_VAR (a) && !DECL_ARTIFICIAL (SSA_NAME_VAR (a))) + { + tree *slot = (tree *) htab_find_slot (ssa_name_hash, a, INSERT); + + if (!*slot) + *slot = a; + else + { + add_coalesce (cl, SSA_NAME_VERSION (a), SSA_NAME_VERSION (*slot), + MUST_COALESCE_COST - 1); + bitmap_set_bit (used_in_copies, SSA_NAME_VERSION (a)); + bitmap_set_bit (used_in_copies, SSA_NAME_VERSION (*slot)); + } + } + } + htab_delete (ssa_name_hash); + } + if (dump_file && (dump_flags & TDF_DETAILS)) + dump_var_map (dump_file, map); + /* Don't calculate live ranges for variables not in the coalesce list. */ partition_view_bitmap (map, used_in_copies, true); BITMAP_FREE (used_in_copies); |