From 5db9ba0c38a08b7313ab2e10b1aabc98c5b73301 Mon Sep 17 00:00:00 2001 From: Diego Novillo Date: Tue, 13 May 2008 14:24:33 -0400 Subject: [PATCH] tree.h (init_phinodes, [...]): Move ... 2008-05-13 Diego Novillo Kenneth Zadeck http://gcc.gnu.org/ml/gcc-patches/2008-05/msg00748.html * tree.h (init_phinodes, fini_phinodes, release_phi_node, phinodes_print_statistics, init_ssanames, fini_ssanames, make_ssa_name, duplicate_ssa_name, duplicate_ssa_name_ptr_info, release_ssa_name, release_defs, replace_ssa_name_symbol, ssanames_print_statistics): Move ... * tree-flow.h: ... here. * tree-ssanames.c (init_ssanames): Add arguments FN and SIZE. Use FN instead of cfun. (make_ssa_name_fn): Rename from make_ssa_name. (pass_release_ssa_names): Add TODO_dump_func to finish flags. * tree-flow-inline.h (make_ssa_name): Move from tree-ssanames.c. Convert to static inline. Call make_ssa_name_fn. * omp-low.c (expand_omp_parallel): * tree-flow-inline.h (redirect_edge_var_map_result): * tree-ssa.c (init_tree_ssa): Add argument FN. Use it instead of cfun. Update all users. Co-Authored-By: Kenneth Zadeck From-SVN: r135270 --- gcc/ChangeLog | 26 ++++++++++++++++++++++++++ gcc/omp-low.c | 2 +- gcc/tree-flow-inline.h | 11 +++++++++++ gcc/tree-flow.h | 23 +++++++++++++++++++++-- gcc/tree-inline.c | 2 +- gcc/tree-optimize.c | 2 +- gcc/tree-ssa.c | 22 +++++++++++----------- gcc/tree-ssanames.c | 38 +++++++++++++++++++++----------------- gcc/tree.h | 22 ---------------------- 9 files changed, 93 insertions(+), 55 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3efb55118a1..cd5f12b6d6e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,29 @@ +2008-05-13 Diego Novillo + Kenneth Zadeck + + http://gcc.gnu.org/ml/gcc-patches/2008-05/msg00748.html + + * tree.h (init_phinodes, fini_phinodes, release_phi_node, + phinodes_print_statistics, init_ssanames, fini_ssanames, + make_ssa_name, duplicate_ssa_name, + duplicate_ssa_name_ptr_info, release_ssa_name, + release_defs, replace_ssa_name_symbol, + ssanames_print_statistics): Move ... + * tree-flow.h: ... here. + * tree-ssanames.c (init_ssanames): Add arguments FN and + SIZE. Use FN instead of cfun. + (make_ssa_name_fn): Rename from make_ssa_name. + (pass_release_ssa_names): Add TODO_dump_func to finish + flags. + * tree-flow-inline.h (make_ssa_name): Move from + tree-ssanames.c. Convert to static inline. Call + make_ssa_name_fn. + * omp-low.c (expand_omp_parallel): + * tree-flow-inline.h (redirect_edge_var_map_result): + * tree-ssa.c (init_tree_ssa): Add argument FN. Use it + instead of cfun. + Update all users. + 2008-05-13 Tom Tromey PR preprocessor/22168: diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 1d3bf7b1f9c..3f2ed91a068 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -2659,7 +2659,7 @@ expand_omp_parallel (struct omp_region *region) if (gimple_in_ssa_p (cfun)) { push_cfun (child_cfun); - init_tree_ssa (); + init_tree_ssa (child_cfun); init_ssa_operands (); cfun->gimple_df->in_ssa_p = true; pop_cfun (); diff --git a/gcc/tree-flow-inline.h b/gcc/tree-flow-inline.h index f2fe01e18d4..a4fe9c29c22 100644 --- a/gcc/tree-flow-inline.h +++ b/gcc/tree-flow-inline.h @@ -1689,4 +1689,15 @@ redirect_edge_var_map_result (edge_var_map *v) { return v->result; } + + +/* Return an SSA_NAME node for variable VAR defined in statement STMT + in function cfun. */ + +static inline tree +make_ssa_name (tree var, tree stmt) +{ + return make_ssa_name_fn (cfun, var, stmt); +} + #endif /* _TREE_FLOW_INLINE_H */ diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 848a9d98695..019cb7ba09c 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -829,6 +829,12 @@ extern void add_phi_arg (tree, tree, edge); extern void remove_phi_args (edge); extern void remove_phi_node (tree, tree, bool); extern tree phi_reverse (tree); +extern void init_phinodes (void); +extern void fini_phinodes (void); +extern void release_phi_node (tree); +#ifdef GATHER_STATISTICS +extern void phinodes_print_statistics (void); +#endif /* In gimple-low.c */ extern void record_vars_into (tree, tree); @@ -893,8 +899,7 @@ extern void redirect_edge_var_map_dup (edge, edge); extern edge_var_map_vector redirect_edge_var_map_vector (edge); extern void redirect_edge_var_map_destroy (void); - -extern void init_tree_ssa (void); +extern void init_tree_ssa (struct function *); extern edge ssa_redirect_edge (edge, basic_block); extern void flush_pending_stmts (edge); extern bool tree_ssa_useless_type_conversion (tree); @@ -924,6 +929,20 @@ void mark_set_for_renaming (bitmap); tree get_current_def (tree); void set_current_def (tree, tree); +/* In tree-ssanames.c */ +extern void init_ssanames (struct function *, int); +extern void fini_ssanames (void); +extern tree make_ssa_name_fn (struct function *, tree, tree); +extern tree duplicate_ssa_name (tree, tree); +extern void duplicate_ssa_name_ptr_info (tree, struct ptr_info_def *); +extern void release_ssa_name (tree); +extern void release_defs (tree); +extern void replace_ssa_name_symbol (tree, tree); + +#ifdef GATHER_STATISTICS +extern void ssanames_print_statistics (void); +#endif + /* In tree-ssa-ccp.c */ bool fold_stmt (tree *); bool fold_stmt_inplace (tree); diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index e7fed4f0723..1ba7b60f6f1 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1301,7 +1301,7 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count, if (src_cfun->gimple_df) { - init_tree_ssa (); + init_tree_ssa (cfun); cfun->gimple_df->in_ssa_p = true; init_ssa_operands (); } diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c index 270353601da..84e1e9d9db3 100644 --- a/gcc/tree-optimize.c +++ b/gcc/tree-optimize.c @@ -333,7 +333,7 @@ static unsigned int execute_init_datastructures (void) { /* Allocate hash tables, arrays and other structures. */ - init_tree_ssa (); + init_tree_ssa (cfun); return 0; } diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 9ba865e241d..150074f7c23 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -944,18 +944,18 @@ uid_ssaname_map_hash (const void *item) /* Initialize global DFA and SSA structures. */ void -init_tree_ssa (void) +init_tree_ssa (struct function *fn) { - cfun->gimple_df = GGC_CNEW (struct gimple_df); - cfun->gimple_df->referenced_vars = htab_create_ggc (20, uid_decl_map_hash, - uid_decl_map_eq, NULL); - cfun->gimple_df->default_defs = htab_create_ggc (20, uid_ssaname_map_hash, - uid_ssaname_map_eq, NULL); - cfun->gimple_df->var_anns = htab_create_ggc (20, var_ann_hash, - var_ann_eq, NULL); - cfun->gimple_df->call_clobbered_vars = BITMAP_GGC_ALLOC (); - cfun->gimple_df->addressable_vars = BITMAP_GGC_ALLOC (); - init_ssanames (); + fn->gimple_df = GGC_CNEW (struct gimple_df); + fn->gimple_df->referenced_vars = htab_create_ggc (20, uid_decl_map_hash, + uid_decl_map_eq, NULL); + fn->gimple_df->default_defs = htab_create_ggc (20, uid_ssaname_map_hash, + uid_ssaname_map_eq, NULL); + fn->gimple_df->var_anns = htab_create_ggc (20, var_ann_hash, + var_ann_eq, NULL); + fn->gimple_df->call_clobbered_vars = BITMAP_GGC_ALLOC (); + fn->gimple_df->addressable_vars = BITMAP_GGC_ALLOC (); + init_ssanames (fn, 0); init_phinodes (); } diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index d418bc19b5f..8d675b43c49 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -67,12 +67,16 @@ unsigned int ssa_name_nodes_reused; unsigned int ssa_name_nodes_created; #endif -/* Initialize management of SSA_NAMEs. */ +/* Initialize management of SSA_NAMEs to default SIZE. If SIZE is + zero use default. */ void -init_ssanames (void) +init_ssanames (struct function *fn, int size) { - SSANAMES (cfun) = VEC_alloc (tree, gc, 50); + if (size < 50) + size = 50; + + SSANAMES (fn) = VEC_alloc (tree, gc, size); /* Version 0 is special, so reserve the first slot in the table. Though currently unused, we may use version 0 in alias analysis as part of @@ -81,8 +85,8 @@ init_ssanames (void) We use VEC_quick_push here because we know that SSA_NAMES has at least 50 elements reserved in it. */ - VEC_quick_push (tree, SSANAMES (cfun), NULL_TREE); - FREE_SSANAMES (cfun) = NULL; + VEC_quick_push (tree, SSANAMES (fn), NULL_TREE); + FREE_SSANAMES (fn) = NULL; } /* Finalize management of SSA_NAMEs. */ @@ -105,13 +109,13 @@ ssanames_print_statistics (void) } #endif -/* Return an SSA_NAME node for variable VAR defined in statement STMT. - STMT may be an empty statement for artificial references (e.g., default - definitions created when a variable is used without a preceding - definition). */ +/* Return an SSA_NAME node for variable VAR defined in statement STMT + in function FN. STMT may be an empty statement for artificial + references (e.g., default definitions created when a variable is + used without a preceding definition). */ tree -make_ssa_name (tree var, tree stmt) +make_ssa_name_fn (struct function *fn, tree var, tree stmt) { tree t; use_operand_p imm; @@ -124,10 +128,10 @@ make_ssa_name (tree var, tree stmt) || TREE_CODE (stmt) == PHI_NODE); /* If our free list has an element, then use it. */ - if (FREE_SSANAMES (cfun)) + if (FREE_SSANAMES (fn)) { - t = FREE_SSANAMES (cfun); - FREE_SSANAMES (cfun) = TREE_CHAIN (FREE_SSANAMES (cfun)); + t = FREE_SSANAMES (fn); + FREE_SSANAMES (fn) = TREE_CHAIN (FREE_SSANAMES (fn)); #ifdef GATHER_STATISTICS ssa_name_nodes_reused++; #endif @@ -135,13 +139,13 @@ make_ssa_name (tree var, tree stmt) /* The node was cleared out when we put it on the free list, so there is no need to do so again here. */ gcc_assert (ssa_name (SSA_NAME_VERSION (t)) == NULL); - VEC_replace (tree, SSANAMES (cfun), SSA_NAME_VERSION (t), t); + VEC_replace (tree, SSANAMES (fn), SSA_NAME_VERSION (t), t); } else { t = make_node (SSA_NAME); - SSA_NAME_VERSION (t) = num_ssa_names; - VEC_safe_push (tree, gc, SSANAMES (cfun), t); + SSA_NAME_VERSION (t) = VEC_length (tree, SSANAMES (fn)); + VEC_safe_push (tree, gc, SSANAMES (fn), t); #ifdef GATHER_STATISTICS ssa_name_nodes_created++; #endif @@ -358,6 +362,6 @@ struct gimple_opt_pass pass_release_ssa_names = 0, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ + TODO_dump_func /* todo_flags_finish */ } }; diff --git a/gcc/tree.h b/gcc/tree.h index 82c44b10a5d..d4bd080ffed 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -3880,28 +3880,6 @@ extern tree make_tree_binfo_stat (unsigned MEM_STAT_DECL); extern tree make_tree_vec_stat (int MEM_STAT_DECL); #define make_tree_vec(t) make_tree_vec_stat (t MEM_STAT_INFO) -/* Tree nodes for SSA analysis. */ - -extern void init_phinodes (void); -extern void fini_phinodes (void); -extern void release_phi_node (tree); -#ifdef GATHER_STATISTICS -extern void phinodes_print_statistics (void); -#endif - -extern void init_ssanames (void); -extern void fini_ssanames (void); -extern tree make_ssa_name (tree, tree); -extern tree duplicate_ssa_name (tree, tree); -extern void duplicate_ssa_name_ptr_info (tree, struct ptr_info_def *); -extern void release_ssa_name (tree); -extern void release_defs (tree); -extern void replace_ssa_name_symbol (tree, tree); - -#ifdef GATHER_STATISTICS -extern void ssanames_print_statistics (void); -#endif - /* Return the (unique) IDENTIFIER_NODE node for a given name. The name is supplied as a char *. */ -- 2.30.2