emit-rtl.c (free_emit_status): Don't check DECL_DEFER_OUTPUT.
authorRichard Henderson <rth@cygnus.com>
Thu, 16 Sep 1999 01:12:25 +0000 (18:12 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Thu, 16 Sep 1999 01:12:25 +0000 (18:12 -0700)
        * emit-rtl.c (free_emit_status): Don't check DECL_DEFER_OUTPUT.
        Free the struct.
        (mark_emit_status): Renamed from mark_emit_state.
        * except.c (mark_eh_status): Renamed from mark_eh_state.
        Check not null before marking.
        (free_eh_status): New.
        * expr.c (mark_expr_status, free_expr_status): New.
        * function.c (free_machine_status): New.
        (free_after_parsing): New.
        (free_after_compilation): Move bits to free_after_parsing; call
        free_eh_status, free_expr_status; zero the marked members of the
        function state.
        (prepare_function_start): No can_garbage_collect.
        Call init_eh_for_function.
        (expand_dummy_function_end): Free up current_function state.
        (mark_function_status): Renamed from mark_function_state.
        (mark_function_chain): No can_garbage_collect.  Call mark_expr_status.
        * function.h (struct function): No can_garbage_collect.
        (free_machine_status, free_after_parsing): Declare.
        (free_eh_status, free_expr_status): Declare.
        * ggc.h (mark_expr_status): Declare.
        * stmt.c (free_stmt_status): Free the struct.
        (mark_stmt_status): Renamed from mark_stmt_state.
        (init_stmt): Don't call init_eh.
        (init_stmt_for_function): Don't call init_eh_for_function.
        * toplev.c (compile_file): Call init_eh.
        (rest_of_compilation): Free basic block info before ggc_collect.
        Call free_after_parsing; conditionally call free_after_compilation.
        * varasm.c (mark_varasm_status): Renamed from mark_varasm_state.
        Check not null before marking.

From-SVN: r29448

gcc/ChangeLog
gcc/emit-rtl.c
gcc/except.c
gcc/expr.c
gcc/function.c
gcc/function.h
gcc/ggc.h
gcc/stmt.c
gcc/toplev.c
gcc/varasm.c

index aff2d71ac04d793d71dcb398f43c3803d6d7891d..63a9a6f120ab6aeeff84a64734ea2dc80922012e 100644 (file)
@@ -1,3 +1,37 @@
+Wed Sep 15 17:56:00 1999  Richard Henderson  <rth@cygnus.com>
+
+       * emit-rtl.c (free_emit_status): Don't check DECL_DEFER_OUTPUT.
+       Free the struct.
+       (mark_emit_status): Renamed from mark_emit_state.
+       * except.c (mark_eh_status): Renamed from mark_eh_state.
+       Check not null before marking.
+       (free_eh_status): New.
+       * expr.c (mark_expr_status, free_expr_status): New.
+       * function.c (free_machine_status): New.
+       (free_after_parsing): New.
+       (free_after_compilation): Move bits to free_after_parsing; call
+       free_eh_status, free_expr_status; zero the marked members of the
+       function state.
+       (prepare_function_start): No can_garbage_collect. 
+       Call init_eh_for_function.
+       (expand_dummy_function_end): Free up current_function state.
+       (mark_function_status): Renamed from mark_function_state.
+       (mark_function_chain): No can_garbage_collect.  Call mark_expr_status.
+       * function.h (struct function): No can_garbage_collect.
+       (free_machine_status, free_after_parsing): Declare.
+       (free_eh_status, free_expr_status): Declare.
+       * ggc.h (mark_expr_status): Declare.
+       * stmt.c (free_stmt_status): Free the struct.
+       (mark_stmt_status): Renamed from mark_stmt_state.
+       (init_stmt): Don't call init_eh.
+       (init_stmt_for_function): Don't call init_eh_for_function.
+       * toplev.c (compile_file): Call init_eh.
+       (rest_of_compilation): Free basic block info before ggc_collect.
+       Call free_after_parsing; conditionally call free_after_compilation.
+       * varasm.c (mark_varasm_status): Renamed from mark_varasm_state.
+       Check not null before marking.
+       (free_varasm_status): Don't check DECL_DEFER_OUTPUT.  Free the struct.
+
 Wed Sep 15 17:53:16 1999  Richard Henderson  <rth@cygnus.com>
 
        * c-lex.c (yylex): Initialize warn.
index 70b080eb37cab109b12aaaf4d8804cb2cc0ff6cf..08f8c275398c42c0999d0f5e059635a572b91d21 100644 (file)
@@ -1609,13 +1609,11 @@ void
 free_emit_status (f)
      struct function *f;
 {
-  if (DECL_DEFER_OUTPUT (f->decl))
-    return;
-
   free (f->emit->x_regno_reg_rtx);
   free (f->emit->regno_pointer_flag);
   free (f->emit->regno_pointer_align);
-  f->emit->x_regno_reg_rtx = 0;
+  free (f->emit);
+  f->emit = NULL;
 }
 \f
 /* Go through all the RTL insn bodies and copy any invalid shared structure.
@@ -3486,7 +3484,7 @@ mark_sequence_stack (ss)
 /* Mark ES for GC.  */
 
 void
-mark_emit_state (es)
+mark_emit_status (es)
      struct emit_status *es;
 {
   rtx *r;
index 9a190c7513d58023131aad2462bf37dc339d6c6f..f063c9ab4acc063c17e55a3effd65f52b7e6e4f9 100644 (file)
@@ -2405,9 +2405,12 @@ mark_tree_label_node (node)
 /* Mark EH for GC.  */
 
 void
-mark_eh_state (eh)
+mark_eh_status (eh)
      struct eh_status *eh;
 {
+  if (eh == 0)
+    return;
+
   mark_eh_stack (&eh->x_ehstack);
   mark_eh_stack (&eh->x_catchstack);
   mark_eh_queue (&eh->x_ehqueue);
@@ -2479,7 +2482,8 @@ init_eh ()
 void
 init_eh_for_function ()
 {
-  current_function->eh = (struct eh_status *) xmalloc (sizeof (struct eh_status));
+  current_function->eh
+    = (struct eh_status *) xmalloc (sizeof (struct eh_status));
 
   ehstack.top = 0;
   catchstack.top = 0;
@@ -2494,6 +2498,14 @@ init_eh_for_function ()
   eh_return_handler = NULL_RTX;
   eh_return_stub_label = NULL_RTX;
 }
+
+void
+free_eh_status (f)
+     struct function *f;
+{
+  free (f->eh);
+  f->eh = NULL;
+}
 \f
 /* This section is for the exception handling specific optimization
    pass.  First are the internal routines, and then the main
index c51a97a93f42628fa1475e08f52db26c0252fcf0..daa06d0e849eb996273f86e21163a261cf889e31 100644 (file)
@@ -290,6 +290,26 @@ init_expr ()
   forced_labels = 0;
 }
 
+void
+mark_expr_status (p)
+     struct expr_status *p;
+{
+  if (p == NULL)
+    return;
+
+  ggc_mark_rtx (p->x_saveregs_value);
+  ggc_mark_rtx (p->x_apply_args_value);
+  ggc_mark_rtx (p->x_forced_labels);
+}
+
+void
+free_expr_status (f)
+     struct function *f;
+{
+  free (f->expr);
+  f->expr = NULL;
+}
+
 /* Small sanity check that the queue is empty at the end of a function.  */
 void
 finish_expr_for_function ()
index c2d585e0cb5b83e8dad7cb4bfe703157dcad3a20..a6c967995c0c789ad37b5a25f3b8a65e98bbd0e9 100644 (file)
@@ -122,6 +122,7 @@ void (*init_machine_status) PROTO((struct function *));
 void (*save_machine_status) PROTO((struct function *));
 void (*restore_machine_status) PROTO((struct function *));
 void (*mark_machine_status) PROTO((struct function *));
+void (*free_machine_status) PROTO((struct function *));
 
 /* Likewise, but for language-specific data.  */
 void (*init_lang_status) PROTO((struct function *));
@@ -276,7 +277,7 @@ static boolean insns_for_mem_comp PROTO ((hash_table_key, hash_table_key));
 static int insns_for_mem_walk   PROTO ((rtx *, void *));
 static void compute_insns_for_mem PROTO ((rtx, rtx, struct hash_table *));
 static void mark_temp_slot PROTO ((struct temp_slot *));
-static void mark_function_state PROTO ((struct function *));
+static void mark_function_status PROTO ((struct function *));
 static void mark_function_chain PROTO ((void *));
 
 \f
@@ -389,6 +390,24 @@ pop_function_context ()
   pop_function_context_from (current_function_decl);
 }
 
+/* Clear out all parts of the state in F that can safely be discarded
+   after the function has been parsed, but not compiled, to let
+   garbage collection reclaim the memory.  */
+
+void
+free_after_parsing (f)
+     struct function *f;
+{
+  /* f->expr->forced_labels is used by code generation.  */
+  /* f->emit->regno_reg_rtx is used by code generation.  */
+  /* f->varasm is used by code generation.  */
+  /* f->eh->eh_return_stub_label is used by code generation.  */
+
+  if (free_lang_status)
+    (*free_lang_status) (f);
+  free_stmt_status (f);
+}
+
 /* Clear out all parts of the state in F that can safely be discarded
    after the function has been compiled, to let garbage collection
    reclaim the memory.  */
@@ -397,18 +416,44 @@ void
 free_after_compilation (f)
      struct function *f;
 {
+  free_eh_status (f);
+  free_expr_status (f);
   free_emit_status (f);
   free_varasm_status (f);
-  free_stmt_status (f);
-  if (free_lang_status)
-    (*free_lang_status) (f);
 
-  if (!DECL_DEFER_OUTPUT (f->decl))
-    {
-      free (f->x_parm_reg_stack_loc);
-      f->can_garbage_collect = 1;
-    }
+  if (free_machine_status)
+    (*free_machine_status) (f);
+
+  free (f->x_parm_reg_stack_loc);
+
+  f->arg_offset_rtx = NULL;
+  f->return_rtx = NULL;
+  f->internal_arg_pointer = NULL;
+  f->x_nonlocal_labels = NULL;
+  f->x_nonlocal_goto_handler_slots = NULL;
+  f->x_nonlocal_goto_handler_labels = NULL;
+  f->x_nonlocal_goto_stack_level = NULL;
+  f->x_cleanup_label = NULL;
+  f->x_return_label = NULL;
+  f->x_save_expr_regs = NULL;
+  f->x_stack_slot_list = NULL;
+  f->x_rtl_expr_chain = NULL;
+  f->x_tail_recursion_label = NULL;
+  f->x_tail_recursion_reentry = NULL;
+  f->x_arg_pointer_save_area = NULL;
+  f->x_context_display = NULL;
+  f->x_trampoline_list = NULL;
+  f->x_parm_birth_insn = NULL;
+  f->x_last_parm_insn = NULL;
+  f->x_parm_reg_stack_loc = NULL;
+  f->x_temp_slots = NULL;
+  f->fixup_var_refs_queue = NULL;
+  f->original_arg_vector = NULL;
+  f->original_decl_initial = NULL;
+  f->inl_last_parm_insn = NULL;
+  f->epilogue_delay_list = NULL;
 }
+
 \f
 /* Allocate fixed slots in the stack frame of the current function.  */
 
@@ -5495,9 +5540,9 @@ static void
 prepare_function_start ()
 {
   current_function = (struct function *) xcalloc (1, sizeof (struct function));
-  current_function->can_garbage_collect = 0;
 
   init_stmt_for_function ();
+  init_eh_for_function ();
 
   cse_not_expected = ! optimize;
 
@@ -5981,6 +6026,10 @@ expand_dummy_function_end ()
 
   /* Outside function body, can't compute type's actual size
      until next function's body starts.  */
+
+  free_after_parsing (current_function);
+  free_after_compilation (current_function);
+  free (current_function);
   current_function = 0;
 }
 
@@ -6664,7 +6713,7 @@ mark_temp_slot (t)
 /* Mark P for GC.  */
 
 static void
-mark_function_state (p)
+mark_function_status (p)
      struct function *p;
 {
   int i;
@@ -6724,20 +6773,14 @@ mark_function_chain (arg)
 
   for (; f; f = f->next_global)
     {
-      if (f->can_garbage_collect)
-       continue;
-
       ggc_mark_tree (f->decl);
 
-      mark_function_state (f);
-      mark_stmt_state (f->stmt);
-      mark_eh_state (f->eh);
-      mark_emit_state (f->emit);
-      mark_varasm_state (f->varasm);
-
-      ggc_mark_rtx (f->expr->x_saveregs_value);
-      ggc_mark_rtx (f->expr->x_apply_args_value);
-      ggc_mark_rtx (f->expr->x_forced_labels);
+      mark_function_status (f);
+      mark_eh_status (f->eh);
+      mark_stmt_status (f->stmt);
+      mark_expr_status (f->expr);
+      mark_emit_status (f->emit);
+      mark_varasm_status (f->varasm);
 
       if (mark_machine_status)
        (*mark_machine_status) (f);
index a574b67ca4b4a9db16fe3548323911bfbd16b0bd..0d70b7d6aed662f3ee65065ead1756958f5d082f 100644 (file)
@@ -184,9 +184,6 @@ struct function
   struct emit_status *emit;
   struct varasm_status *varasm;
 
-  /* Nonzero if we are done compiling this function.  */
-  int can_garbage_collect;
-  
   /* For function.c.  */
 
   /* Name of this function.  */
@@ -539,6 +536,7 @@ extern void (*init_machine_status)  PROTO((struct function *));
 extern void (*mark_machine_status)     PROTO((struct function *));
 extern void (*save_machine_status)     PROTO((struct function *));
 extern void (*restore_machine_status)  PROTO((struct function *));
+extern void (*free_machine_status)     PROTO((struct function *));
 
 /* Likewise, but for language-specific data.  */
 extern void (*init_lang_status)         PROTO((struct function *));
@@ -551,12 +549,16 @@ extern void (*free_lang_status)         PROTO((struct function *));
 extern void save_tree_status           PROTO((struct function *));
 extern void restore_tree_status                PROTO((struct function *));
 extern void restore_emit_status                PROTO((struct function *));
+extern void free_after_parsing         PROTO((struct function *));
 extern void free_after_compilation     PROTO((struct function *));
 
 extern void init_varasm_status         PROTO((struct function *));
 extern void free_varasm_status         PROTO((struct function *));
 extern void free_emit_status           PROTO((struct function *));
 extern void free_stmt_status            PROTO((struct function *));
+extern void free_eh_status             PROTO((struct function *));
+extern void free_expr_status           PROTO((struct function *));
+
 extern rtx get_first_block_beg         PROTO((void));
 
 extern void init_virtual_regs          PROTO((struct emit_status *));
index da29d249bff445c58575cccb4ef8ff126872c644..20b3bb8771dd128f62dc2c2ef9a741e8db55de40 100644 (file)
--- a/gcc/ggc.h
+++ b/gcc/ggc.h
@@ -33,6 +33,7 @@ extern int ggc_p;
    just forward-declare them here.  */
 struct eh_status;
 struct emit_status;
+struct expr_status;
 struct hash_table;
 struct label_node;
 struct rtvec_def;
@@ -121,8 +122,9 @@ void lang_mark_false_label_stack PROTO ((struct label_node *));
 
 /* Mark functions for various structs scattered about.  */
 
-void mark_eh_state PROTO ((struct eh_status *));
-void mark_stmt_state PROTO ((struct stmt_status *));
-void mark_emit_state PROTO ((struct emit_status *));
-void mark_varasm_state PROTO ((struct varasm_status *));
+void mark_eh_status PROTO ((struct eh_status *));
+void mark_emit_status PROTO ((struct emit_status *));
+void mark_expr_status PROTO ((struct expr_status *));
+void mark_stmt_status PROTO ((struct stmt_status *));
+void mark_varasm_status PROTO ((struct varasm_status *));
 void mark_optab PROTO ((void *));
index 068803cd4d44fe80f0ae560bfc6ba72000bab666..fcfdb06e4d2daf61f1197f9d739968b028675f23 100644 (file)
@@ -561,13 +561,15 @@ free_stmt_status (f)
   /* We're about to free the function obstack.  If we hold pointers to
      things allocated there, then we'll try to mark them when we do
      GC.  So, we clear them out here explicitly.  */
-  f->stmt->x_goto_fixup_chain = 0;
+
+  free (f->stmt);
+  f->stmt = NULL;
 }
 
 /* Mark P for GC.  */
 
 void
-mark_stmt_state (p)
+mark_stmt_status (p)
      struct stmt_status *p;
 {
   if (p == 0)
@@ -590,7 +592,6 @@ void
 init_stmt ()
 {
   gcc_obstack_init (&stmt_obstack);
-  init_eh ();
 }
 
 void
@@ -617,8 +618,6 @@ init_stmt_for_function ()
   expr_stmts_for_value = 0;
   last_expr_type = 0;
   last_expr_value = NULL_RTX;
-
-  init_eh_for_function ();
 }
 \f
 /* Return nonzero if anything is pushed on the loop, condition, or case
index e14c20a731884a029a5d2c2c4e391c27ea030dcf..aa3d62ed1d8547f7cd22b643b72e5c3ec642f7c9 100644 (file)
@@ -2862,6 +2862,7 @@ compile_file (name)
   init_decl_processing ();
   init_optabs ();
   init_stmt ();
+  init_eh ();
   init_loop ();
   init_reload ();
   init_alias_once ();
@@ -4425,6 +4426,8 @@ rest_of_compilation (decl)
 
              /* Show no temporary slots allocated.  */
              init_temp_slots ();
+
+             free_basic_block_vars (0);
           });
 
   /* Make sure volatile mem refs aren't considered valid operands for
@@ -4439,8 +4442,9 @@ rest_of_compilation (decl)
   init_recog_no_volatile ();
 
   /* We're done with this function.  Free up memory if we can.  */
-  free_after_compilation (current_function);
-
+  free_after_parsing (current_function);
+  if (! DECL_DEFER_OUTPUT (decl))
+    free_after_compilation (current_function);
   current_function = 0;
 
   if (ggc_p)
@@ -4450,9 +4454,6 @@ rest_of_compilation (decl)
      *except* what is spent in this function.  */
 
   parse_time -= get_run_time () - start_time;
-
-  /* Reset global variables.  */
-  free_basic_block_vars (0);
 }
 \f
 static void
index 779aeaa04d83528a5a19f9da12c7cf73a86038c4..cf56a09f3ad071978bd22df61f52d06bce880cdd 100644 (file)
@@ -3228,9 +3228,12 @@ mark_pool_sym_hash_table (pps)
 /* Mark P for GC.  */
 
 void
-mark_varasm_state (p)
-  struct varasm_status *p;
+mark_varasm_status (p)
+     struct varasm_status *p;
 {
+  if (p == NULL)
+    return;
+
   mark_pool_constant (p->x_first_pool);
   mark_pool_sym_hash_table (p->x_const_rtx_sym_hash_table);
   ggc_mark_rtx (p->x_const_double_chain);
@@ -3246,17 +3249,11 @@ free_varasm_status (f)
 {
   struct varasm_status *p;
 
-  if (DECL_DEFER_OUTPUT (f->decl))
-    return;
-
   p = f->varasm;
   free (p->x_const_rtx_hash_table);
   free (p->x_const_rtx_sym_hash_table);
-
-  p->x_first_pool = p->x_last_pool = 0;
-  p->x_const_rtx_hash_table = 0;
-  p->x_const_rtx_sym_hash_table = 0;
-  p->x_const_double_chain = 0;
+  free (p);
+  f->varasm = NULL;
 }
 \f
 enum kind { RTX_DOUBLE, RTX_INT };