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]

[tree-ssa] GGC friendly function save/restore


Hi,
fopr both ggc collecting and recursive inlining I need saved_tree/saved_args to
be externally visible.
Regtested/bootstrapped i686-pc-gnu-linux.
I also tested it in combination with other two today patches on x86_64-linux.
Sorry for not doing it in isolation, but x86-64 machine is currently down.

OK?

Honza

2003-11-28  Jan Hubicka  <jh@suse.cz>
	* function.h (struct function): Add saved_tree/saved_args.
	* toplev.c (rest_of_compilation): Do not clear cfun.
	* tree-optimize.c (tree_rest_of_compilation): Use cfun to save/restore
	function body.
Index: function.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.h,v
retrieving revision 1.83.2.18
diff -c -3 -p -r1.83.2.18 function.h
*** function.h	15 Nov 2003 19:44:36 -0000	1.83.2.18
--- function.h	28 Nov 2003 01:26:34 -0000
*************** struct function GTY(())
*** 527,532 ****
--- 527,537 ----
  
    /* Nonzero if the rtl inliner has saved the function for inlining.  */
    unsigned int saved_for_inline : 1;
+ 
+   /* Saved tree and arguments during tree optimization.  Used later for
+      inlining */
+   tree GTY(()) saved_tree;
+   tree GTY(()) saved_args;
  };
  
  /* The function currently being compiled.  */
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.654.2.80
diff -c -3 -p -r1.654.2.80 toplev.c
*** toplev.c	25 Nov 2003 02:09:53 -0000	1.654.2.80
--- toplev.c	28 Nov 2003 01:26:34 -0000
*************** rest_of_compilation (tree decl)
*** 3690,3698 ****
        free_after_compilation (cfun);
        DECL_SAVED_INSNS (decl) = 0;
      }
-   cfun = 0;
- 
-   ggc_collect ();
  
    timevar_pop (TV_REST_OF_COMPILATION);
  }
--- 3690,3695 ----
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 1.1.4.79
diff -c -3 -p -r1.1.4.79 tree-optimize.c
*** tree-optimize.c	25 Nov 2003 14:18:43 -0000	1.1.4.79
--- tree-optimize.c	28 Nov 2003 01:26:35 -0000
*************** void
*** 266,272 ****
  tree_rest_of_compilation (tree fndecl, bool nested_p)
  {
    location_t saved_loc;
!   tree saved_tree = NULL, saved_args = NULL, chain;
  
    timevar_push (TV_EXPAND);
  
--- 270,276 ----
  tree_rest_of_compilation (tree fndecl, bool nested_p)
  {
    location_t saved_loc;
!   tree chain;
  
    timevar_push (TV_EXPAND);
  
*************** tree_rest_of_compilation (tree fndecl, b
*** 293,304 ****
       it inline somewhere else.  This means not lowering some constructs
       such as exception handling.  */
    if (DECL_INLINE (fndecl) && flag_inline_trees)
!     {
!       saved_tree = save_body (fndecl, &saved_args);
!       /* ??? We're saving this value here on the stack.  Don't gc it.  */
!       nested_p = true;
!     }
! 
    /* Mudflap-instrument any relevant declarations.  */
    if (flag_mudflap)
      mudflap_c_function_decls (fndecl);
--- 297,305 ----
       it inline somewhere else.  This means not lowering some constructs
       such as exception handling.  */
    if (DECL_INLINE (fndecl) && flag_inline_trees)
!     cfun->saved_tree = save_body (fndecl, &cfun->saved_args);
!   else
!     cfun->saved_tree = NULL;
    /* Mudflap-instrument any relevant declarations.  */
    if (flag_mudflap)
      mudflap_c_function_decls (fndecl);
*************** tree_rest_of_compilation (tree fndecl, b
*** 400,405 ****
--- 403,417 ----
    /* Run the optimizers and output the assembler code for this function.  */
    rest_of_compilation (fndecl);
  
+   if (cfun->saved_tree)
+     {
+       /* We might need the body of this function so that we can expand
+          it inline somewhere else.  */
+       DECL_SAVED_TREE (fndecl) = cfun->saved_tree;
+       DECL_ARGUMENTS (fndecl) = cfun->saved_args;
+     }
+   cfun = 0;
+ 
    /* Undo the GC context switch.  */
    if (nested_p)
      ggc_pop_context ();
*************** tree_rest_of_compilation (tree fndecl, b
*** 430,442 ****
  
    /* ??? Looks like some of this could be combined.  */
  
-   if (DECL_INLINE (fndecl) && flag_inline_trees)
-     {
-       /* We might need the body of this function so that we can expand
-          it inline somewhere else.  */
-       DECL_SAVED_TREE (fndecl) = saved_tree;
-       DECL_ARGUMENTS (fndecl) = saved_args;
-     }
  
    /* If possible, obliterate the body of the function so that it can
       be garbage collected.  */
--- 443,448 ----


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