This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

CFG infrastructure for CFG inliner


Hi,
this patch contains the cfg changes needed for cfg inlining.  Basically it breaks out
the cfg initialization code and makes cfg allocation to happen later to conserve
some memory.
Regtested bootstrapped i686-pc-gnu-linux as a part of cfg patch, separate
testing in progress, OK if it passes?

Honza

2005-05-12  Jan Hubicka  <jh@suse.cz>
	(FOR_ALL_BB_FN): New macro.
	(init_flow): Initialize cfg structure.
	* function.c (allocate_struct_function): Do not initialize cfg structure.
	* tree-cfg.c (init_empty_tree_cfg): Break out from ...
	(build_tree_cfg): ... here.
	* tree-flow.h (init_empty_tree_cfg): Declare.
Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.254
diff -c -3 -p -r1.254 basic-block.h
*** basic-block.h	26 Apr 2005 14:27:35 -0000	1.254
--- basic-block.h	12 May 2005 16:14:01 -0000
*************** extern bool rediscover_loops_after_threa
*** 444,449 ****
--- 444,452 ----
  #define FOR_ALL_BB(BB) \
    for (BB = ENTRY_BLOCK_PTR; BB; BB = BB->next_bb)
  
+ #define FOR_ALL_BB_FN(BB, FN) \
+   for (BB = ENTRY_BLOCK_PTR_FOR_FUNCTION (FN); BB; BB = BB->next_bb)
+ 
  /* Special labels found during CFG build.  */
  
  extern GTY(()) rtx label_value_list;
Index: cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfg.c,v
retrieving revision 1.91
diff -c -3 -p -r1.91 cfg.c
*** cfg.c	3 May 2005 19:05:59 -0000	1.91
--- cfg.c	12 May 2005 16:14:01 -0000
*************** static void free_edge (edge);
*** 78,84 ****
  void
  init_flow (void)
  {
! 
    ENTRY_BLOCK_PTR = ggc_alloc_cleared (sizeof (struct basic_block_def));
    ENTRY_BLOCK_PTR->index = ENTRY_BLOCK;
    EXIT_BLOCK_PTR = ggc_alloc_cleared (sizeof (struct basic_block_def));
--- 78,86 ----
  void
  init_flow (void)
  {
!   if (!cfun->cfg)
!     cfun->cfg = ggc_alloc_cleared (sizeof (struct control_flow_graph));
!   n_edges = 0;
    ENTRY_BLOCK_PTR = ggc_alloc_cleared (sizeof (struct basic_block_def));
    ENTRY_BLOCK_PTR->index = ENTRY_BLOCK;
    EXIT_BLOCK_PTR = ggc_alloc_cleared (sizeof (struct basic_block_def));
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.620
diff -c -3 -p -r1.620 function.c
*** function.c	4 May 2005 01:38:14 -0000	1.620
--- function.c	12 May 2005 16:14:02 -0000
*************** allocate_struct_function (tree fndecl)
*** 3741,3749 ****
    tree fntype = fndecl ? TREE_TYPE (fndecl) : NULL_TREE;
  
    cfun = ggc_alloc_cleared (sizeof (struct function));
-   cfun->cfg = ggc_alloc_cleared (sizeof (struct control_flow_graph));
- 
-   n_edges = 0;
  
    cfun->stack_alignment_needed = STACK_BOUNDARY;
    cfun->preferred_stack_boundary = STACK_BOUNDARY;
--- 3741,3746 ----
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.185
diff -c -3 -p -r2.185 tree-cfg.c
*** tree-cfg.c	10 May 2005 22:33:27 -0000	2.185
--- tree-cfg.c	12 May 2005 16:14:02 -0000
*************** static tree find_case_label_for_value (t
*** 132,137 ****
--- 132,157 ----
  static bool phi_alternatives_equal (basic_block, edge, edge);
  static bool cleanup_forwarder_blocks (void);
  
+ void
+ init_empty_tree_cfg (void)
+ {
+   /* Initialize the basic block array.  */
+   init_flow ();
+   profile_status = PROFILE_ABSENT;
+   n_basic_blocks = 0;
+   last_basic_block = 0;
+   VARRAY_BB_INIT (basic_block_info, initial_cfg_capacity, "basic_block_info");
+ 
+   /* Build a mapping of labels to their associated blocks.  */
+   VARRAY_BB_INIT (label_to_block_map, initial_cfg_capacity,
+ 		  "label to block map");
+ 
+   ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR;
+   EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR;
+ 
+   create_block_annotation (ENTRY_BLOCK_PTR);
+   create_block_annotation (EXIT_BLOCK_PTR);
+ }
  
  /*---------------------------------------------------------------------------
  			      Create basic blocks
*************** build_tree_cfg (tree *tp)
*** 146,165 ****
    /* Register specific tree functions.  */
    tree_register_cfg_hooks ();
  
-   /* Initialize the basic block array.  */
-   init_flow ();
-   profile_status = PROFILE_ABSENT;
-   n_basic_blocks = 0;
-   last_basic_block = 0;
-   VARRAY_BB_INIT (basic_block_info, initial_cfg_capacity, "basic_block_info");
    memset ((void *) &cfg_stats, 0, sizeof (cfg_stats));
  
!   /* Build a mapping of labels to their associated blocks.  */
!   VARRAY_BB_INIT (label_to_block_map, initial_cfg_capacity,
! 		  "label to block map");
! 
!   ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR;
!   EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR;
  
    found_computed_goto = 0;
    make_blocks (*tp);
--- 166,174 ----
    /* Register specific tree functions.  */
    tree_register_cfg_hooks ();
  
    memset ((void *) &cfg_stats, 0, sizeof (cfg_stats));
  
!   init_empty_tree_cfg ();
  
    found_computed_goto = 0;
    make_blocks (*tp);
*************** build_tree_cfg (tree *tp)
*** 176,184 ****
    if (n_basic_blocks == 0)
      create_empty_bb (ENTRY_BLOCK_PTR);
  
-   create_block_annotation (ENTRY_BLOCK_PTR);
-   create_block_annotation (EXIT_BLOCK_PTR);
-   
    /* Adjust the size of the array.  */
    VARRAY_GROW (basic_block_info, n_basic_blocks);
  
--- 185,190 ----
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow.h,v
retrieving revision 2.103
diff -c -3 -p -r2.103 tree-flow.h
*** tree-flow.h	8 May 2005 15:07:22 -0000	2.103
--- tree-flow.h	12 May 2005 16:14:03 -0000
*************** extern tree gimplify_build2 (block_stmt_
*** 541,546 ****
--- 541,547 ----
  			     tree, tree, tree);
  extern tree gimplify_build3 (block_stmt_iterator *, enum tree_code,
  			     tree, tree, tree, tree);
+ extern void init_empty_tree_cfg (void);
  
  /* In tree-pretty-print.c.  */
  extern void dump_generic_bb (FILE *, basic_block, int, int);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]