From 9defb1fe37d0ff78a3a8f4729e4f51a957ec902e Mon Sep 17 00:00:00 2001 From: Diego Novillo Date: Fri, 16 May 2008 09:36:26 -0400 Subject: [PATCH] [multiple changes] 2008-05-16 Nathan Froyd * tree-flow.h (init_empty_tree_cfg_for_function): Declare. * tree-cfg.c (init_empty_tree_cfg_for_function): Define. (init_empty_tree_cfg): Call it. 2008-05-16 Kenneth Zadeck * cfg.c (init_flow): Add argument THE_FUN. Use it instead of cfun. Update all users. From-SVN: r135418 --- gcc/ChangeLog | 11 +++++++++++ gcc/basic-block.h | 5 ++++- gcc/cfg.c | 24 ++++++++++++++---------- gcc/tree-cfg.c | 41 ++++++++++++++++++++++++++++------------- 4 files changed, 57 insertions(+), 24 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1c2ac87f620..50eb528a9e9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2008-05-16 Nathan Froyd + + * tree-flow.h (init_empty_tree_cfg_for_function): Declare. + * tree-cfg.c (init_empty_tree_cfg_for_function): Define. + (init_empty_tree_cfg): Call it. + +2008-05-16 Kenneth Zadeck + + * cfg.c (init_flow): Add argument THE_FUN. Use it + instead of cfun. Update all users. + 2008-05-16 Kenneth Zadeck * doc/invoke.text (-fdump-tree-*-verbose): New option. diff --git a/gcc/basic-block.h b/gcc/basic-block.h index a2598df3d34..53e8a8b5685 100644 --- a/gcc/basic-block.h +++ b/gcc/basic-block.h @@ -414,9 +414,12 @@ struct control_flow_graph GTY(()) #define n_edges_for_function(FN) ((FN)->cfg->x_n_edges) #define last_basic_block_for_function(FN) ((FN)->cfg->x_last_basic_block) #define label_to_block_map_for_function(FN) ((FN)->cfg->x_label_to_block_map) +#define profile_status_for_function(FN) ((FN)->cfg->x_profile_status) #define BASIC_BLOCK_FOR_FUNCTION(FN,N) \ (VEC_index (basic_block, basic_block_info_for_function(FN), (N))) +#define SET_BASIC_BLOCK_FOR_FUNCTION(FN,N,BB) \ + (VEC_replace (basic_block, basic_block_info_for_function(FN), (N), (BB))) /* Defines for textual backward source compatibility. */ #define ENTRY_BLOCK_PTR (cfun->cfg->x_entry_block_ptr) @@ -839,7 +842,7 @@ extern bool br_prob_note_reliable_p (const_rtx); /* In cfg.c */ extern void dump_regset (regset, FILE *); extern void debug_regset (regset); -extern void init_flow (void); +extern void init_flow (struct function *); extern void debug_bb (basic_block); extern basic_block debug_bb_n (int); extern void dump_regset (regset, FILE *); diff --git a/gcc/cfg.c b/gcc/cfg.c index fe8dba984cf..e8bf789480b 100644 --- a/gcc/cfg.c +++ b/gcc/cfg.c @@ -81,17 +81,21 @@ static void free_edge (edge); /* Called once at initialization time. */ void -init_flow (void) +init_flow (struct function *the_fun) { - if (!cfun->cfg) - cfun->cfg = GGC_CNEW (struct control_flow_graph); - n_edges = 0; - ENTRY_BLOCK_PTR = GGC_CNEW (struct basic_block_def); - ENTRY_BLOCK_PTR->index = ENTRY_BLOCK; - EXIT_BLOCK_PTR = GGC_CNEW (struct basic_block_def); - EXIT_BLOCK_PTR->index = EXIT_BLOCK; - ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR; - EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR; + if (!the_fun->cfg) + the_fun->cfg = GGC_CNEW (struct control_flow_graph); + n_edges_for_function (the_fun) = 0; + ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun) + = GGC_CNEW (struct basic_block_def); + ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun)->index = ENTRY_BLOCK; + EXIT_BLOCK_PTR_FOR_FUNCTION (the_fun) + = GGC_CNEW (struct basic_block_def); + EXIT_BLOCK_PTR_FOR_FUNCTION (the_fun)->index = EXIT_BLOCK; + ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun)->next_bb + = EXIT_BLOCK_PTR_FOR_FUNCTION (the_fun); + EXIT_BLOCK_PTR_FOR_FUNCTION (the_fun)->prev_bb + = ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun); } /* Helper function for remove_edge and clear_edges. Frees edge structure diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 2de19c4b7a3..4eab1fd449e 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -114,26 +114,41 @@ static edge find_taken_edge_switch_expr (basic_block, tree); static tree find_case_label_for_value (tree, tree); void -init_empty_tree_cfg (void) +init_empty_tree_cfg_for_function (struct function *fn) { /* Initialize the basic block array. */ - init_flow (); - profile_status = PROFILE_ABSENT; - n_basic_blocks = NUM_FIXED_BLOCKS; - last_basic_block = NUM_FIXED_BLOCKS; - basic_block_info = VEC_alloc (basic_block, gc, initial_cfg_capacity); - VEC_safe_grow_cleared (basic_block, gc, basic_block_info, + init_flow (fn); + profile_status_for_function (fn) = PROFILE_ABSENT; + n_basic_blocks_for_function (fn) = NUM_FIXED_BLOCKS; + last_basic_block_for_function (fn) = NUM_FIXED_BLOCKS; + basic_block_info_for_function (fn) + = VEC_alloc (basic_block, gc, initial_cfg_capacity); + VEC_safe_grow_cleared (basic_block, gc, + basic_block_info_for_function (fn), initial_cfg_capacity); /* Build a mapping of labels to their associated blocks. */ - label_to_block_map = VEC_alloc (basic_block, gc, initial_cfg_capacity); - VEC_safe_grow_cleared (basic_block, gc, label_to_block_map, + label_to_block_map_for_function (fn) + = VEC_alloc (basic_block, gc, initial_cfg_capacity); + VEC_safe_grow_cleared (basic_block, gc, + label_to_block_map_for_function (fn), initial_cfg_capacity); - SET_BASIC_BLOCK (ENTRY_BLOCK, ENTRY_BLOCK_PTR); - SET_BASIC_BLOCK (EXIT_BLOCK, EXIT_BLOCK_PTR); - ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR; - EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR; + SET_BASIC_BLOCK_FOR_FUNCTION (fn, ENTRY_BLOCK, + ENTRY_BLOCK_PTR_FOR_FUNCTION (fn)); + SET_BASIC_BLOCK_FOR_FUNCTION (fn, EXIT_BLOCK, + EXIT_BLOCK_PTR_FOR_FUNCTION (fn)); + + ENTRY_BLOCK_PTR_FOR_FUNCTION (fn)->next_bb + = EXIT_BLOCK_PTR_FOR_FUNCTION (fn); + EXIT_BLOCK_PTR_FOR_FUNCTION (fn)->prev_bb + = ENTRY_BLOCK_PTR_FOR_FUNCTION (fn); +} + +void +init_empty_tree_cfg (void) +{ + init_empty_tree_cfg_for_function (cfun); } /*--------------------------------------------------------------------------- -- 2.30.2