[multiple changes]
authorDiego Novillo <dnovillo@gcc.gnu.org>
Fri, 16 May 2008 13:36:26 +0000 (09:36 -0400)
committerDiego Novillo <dnovillo@gcc.gnu.org>
Fri, 16 May 2008 13:36:26 +0000 (09:36 -0400)
2008-05-16  Nathan Froyd  <froydnj@codesourcery.com>

* 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 <zadeck@naturalbridge.com>

* cfg.c (init_flow): Add argument THE_FUN.  Use it
instead of cfun.  Update all users.

From-SVN: r135418

gcc/ChangeLog
gcc/basic-block.h
gcc/cfg.c
gcc/tree-cfg.c

index 1c2ac87f62079f8ef9709556f21c24b19e7ee725..50eb528a9e97e77e51b6af35b16637de09575110 100644 (file)
@@ -1,3 +1,14 @@
+2008-05-16  Nathan Froyd  <froydnj@codesourcery.com>
+
+       * 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 <zadeck@naturalbridge.com>
+
+       * cfg.c (init_flow): Add argument THE_FUN.  Use it
+       instead of cfun.  Update all users.
+
 2008-05-16  Kenneth Zadeck <zadeck@naturalbridge.com>
 
        * doc/invoke.text (-fdump-tree-*-verbose): New option.
index a2598df3d34508b23372ac20bcb22bc8dba3d712..53e8a8b5685d92b77f1ae641743d5214f0e8d124 100644 (file)
@@ -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 *);
index fe8dba984cf576dbf6dd28bf59d3aadddb2d6408..e8bf789480bf9129745428e0a2aed8c917f535a3 100644 (file)
--- 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);
 }
 \f
 /* Helper function for remove_edge and clear_edges.  Frees edge structure
index 2de19c4b7a3faae2dcaa678e184a0489a9f77c05..4eab1fd449ef7603ef1f5ff9a9d99b67ec415bd8 100644 (file)
@@ -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);
 }
 
 /*---------------------------------------------------------------------------