diff options
author | Bin Cheng <bin.cheng@arm.com> | 2018-05-25 10:35:44 +0000 |
---|---|---|
committer | Bin Cheng <amker@gcc.gnu.org> | 2018-05-25 10:35:44 +0000 |
commit | e3bfa3775a7714fc5c5a8fee06e2c0f42c1fcd34 (patch) | |
tree | 24d850051850f9a7fea69c5a4e13e800d0166ddf /gcc/tree-outof-ssa.c | |
parent | 34f7080eb0d738c4f27d7990907172eb907055be (diff) | |
download | gcc-e3bfa3775a7714fc5c5a8fee06e2c0f42c1fcd34.zip gcc-e3bfa3775a7714fc5c5a8fee06e2c0f42c1fcd34.tar.gz gcc-e3bfa3775a7714fc5c5a8fee06e2c0f42c1fcd34.tar.bz2 |
tree-outof-ssa.c (tree-ssa.h, tree-dfa.h): Include header files.
* tree-outof-ssa.c (tree-ssa.h, tree-dfa.h): Include header files.
(create_default_def, for_all_parms): Moved from tree-ssa-coalesce.c.
(parm_default_def_partition_arg): Ditto.
(set_parm_default_def_partition): Ditto.
(get_parm_default_def_partitions): Ditto and make it static.
(get_undefined_value_partitions): Ditto and make it static.
(remove_ssa_form): Refactor call to init_var_map here.
* tree-ssa-coalesce.c (build_ssa_conflict_graph): Support live range
computation for loop region.
(coalesce_partitions, compute_optimized_partition_bases): Ditto.
(register_default_def): Delete.
(for_all_parms, create_default_def): Move to tree-outof-ssa.c.
(parm_default_def_partition_arg): Ditto.
(set_parm_default_def_partition): Ditto.
(get_parm_default_def_partitions): Ditto and make it static.
(get_undefined_value_partitions): Ditto and make it static.
(coalesce_with_default, coalesce_with_default): Update comment.
(create_coalesce_list_for_region): New func factored out from
create_outofssa_var_map.
(populate_coalesce_list_for_outofssa): New func factored out from
create_outofssa_var_map and coalesce_ssa_name.
(create_outofssa_var_map): Delete.
(coalesce_ssa_name): Refactor to support live range computation.
* tree-ssa-coalesce.h (coalesce_ssa_name): Change decl.
(get_parm_default_def_partitions): Delete.
(get_undefined_value_partitions): Ditto.
* tree-ssa-live.c (init_var_map, delete_var_map): Support live range
computation for loop region.
(new_tree_live_info, loe_visit_block): Ditto.
(live_worklist, set_var_live_on_entry): Ditto.
(calculate_live_on_exit, verify_live_on_entry): Ditto.
* tree-ssa-live.h (struct _var_map): New fields.
(init_var_map): Change decl.
(region_contains_p): New.
From-SVN: r260747
Diffstat (limited to 'gcc/tree-outof-ssa.c')
-rw-r--r-- | gcc/tree-outof-ssa.c | 102 |
1 files changed, 101 insertions, 1 deletions
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c index 59bdcd6..3f880ef 100644 --- a/gcc/tree-outof-ssa.c +++ b/gcc/tree-outof-ssa.c @@ -27,10 +27,12 @@ along with GCC; see the file COPYING3. If not see #include "gimple.h" #include "cfghooks.h" #include "ssa.h" +#include "tree-ssa.h" #include "memmodel.h" #include "emit-rtl.h" #include "gimple-pretty-print.h" #include "diagnostic-core.h" +#include "tree-dfa.h" #include "stor-layout.h" #include "cfgrtl.h" #include "cfganal.h" @@ -888,6 +890,102 @@ rewrite_trees (var_map map) } } +/* Create a default def for VAR. */ + +static void +create_default_def (tree var, void *arg ATTRIBUTE_UNUSED) +{ + if (!is_gimple_reg (var)) + return; + + tree ssa = get_or_create_ssa_default_def (cfun, var); + gcc_assert (ssa); +} + +/* Call CALLBACK for all PARM_DECLs and RESULT_DECLs for which + assign_parms may ask for a default partition. */ + +static void +for_all_parms (void (*callback)(tree var, void *arg), void *arg) +{ + for (tree var = DECL_ARGUMENTS (current_function_decl); var; + var = DECL_CHAIN (var)) + callback (var, arg); + if (!VOID_TYPE_P (TREE_TYPE (DECL_RESULT (current_function_decl)))) + callback (DECL_RESULT (current_function_decl), arg); + if (cfun->static_chain_decl) + callback (cfun->static_chain_decl, arg); +} + +/* We need to pass two arguments to set_parm_default_def_partition, + but for_all_parms only supports one. Use a pair. */ + +typedef std::pair<var_map, bitmap> parm_default_def_partition_arg; + +/* Set in ARG's PARTS bitmap the bit corresponding to the partition in + ARG's MAP containing VAR's default def. */ + +static void +set_parm_default_def_partition (tree var, void *arg_) +{ + parm_default_def_partition_arg *arg = (parm_default_def_partition_arg *)arg_; + var_map map = arg->first; + bitmap parts = arg->second; + + if (!is_gimple_reg (var)) + return; + + tree ssa = ssa_default_def (cfun, var); + gcc_assert (ssa); + + int version = var_to_partition (map, ssa); + gcc_assert (version != NO_PARTITION); + + bool changed = bitmap_set_bit (parts, version); + gcc_assert (changed); +} + +/* Allocate and return a bitmap that has a bit set for each partition + that contains a default def for a parameter. */ + +static bitmap +get_parm_default_def_partitions (var_map map) +{ + bitmap parm_default_def_parts = BITMAP_ALLOC (NULL); + + parm_default_def_partition_arg + arg = std::make_pair (map, parm_default_def_parts); + + for_all_parms (set_parm_default_def_partition, &arg); + + return parm_default_def_parts; +} + +/* Allocate and return a bitmap that has a bit set for each partition + that contains an undefined value. */ + +static bitmap +get_undefined_value_partitions (var_map map) +{ + bitmap undefined_value_parts = BITMAP_ALLOC (NULL); + + for (unsigned int i = 1; i < num_ssa_names; i++) + { + tree var = ssa_name (i); + if (var + && !virtual_operand_p (var) + && !has_zero_uses (var) + && ssa_undefined_value_p (var)) + { + const int p = var_to_partition (map, var); + if (p != NO_PARTITION) + bitmap_set_bit (undefined_value_parts, p); + } + } + + return undefined_value_parts; +} + /* Given the out-of-ssa info object SA (with prepared partitions) eliminate all phi nodes in all basic blocks. Afterwards no basic block will have phi nodes anymore and there are possibly @@ -945,7 +1043,9 @@ remove_ssa_form (bool perform_ter, struct ssaexpand *sa) bitmap values = NULL; var_map map; - map = coalesce_ssa_name (); + for_all_parms (create_default_def, NULL); + map = init_var_map (num_ssa_names); + coalesce_ssa_name (map); /* Return to viewing the variable list as just all reference variables after coalescing has been performed. */ |