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]

[PCH] GC 'machine' and 'language' fields of function structure



Long, but boring.

Tested by bootstrap on x86-linux and a testrun on powerpc-eabisim; all
the other ports I changed seemed to be unbuildable for one reason or
another (but many of the builds got far enough to reassure me I didn't
make any syntax errors).

-- 
Geoff Keating <geoffk@redhat.com>

===File ~/patches/pchbranch-xstatusgc.patch=================
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ChangeLog,v
retrieving revision 1.12690.2.7
diff -p -u -p -r1.12690.2.7 ChangeLog
--- ChangeLog	2002/02/18 17:14:17	1.12690.2.7
+++ ChangeLog	2002/02/19 02:43:53
@@ -1,5 +1,56 @@
 2002-02-18  Geoffrey Keating  <geoffk@redhat.com>
 
+	* function.h (free_lang_status): Mark as obsolete.
+	* function.c (free_lang_status): Mark as obsolete.
+	* c-decl.c (push_c_function_context): Use GC to allocate and free
+	struct language_function.
+	(pop_c_function_context): Likewise.
+	* c-common.c (mark_c_language_function): Mark struct
+	language_function.
+
+	* doc/tm.texi (Per-Function Data): Don't document free_machine_status.
+	Document that the machine_function structures must be allocated
+	using GC.  Update mark_machine_status documentation.
+	* function.h: Don't declare free_machine_status.
+	* function.c (free_machine_status): Don't define. 
+	(free_after_compilation): Don't call free_machine_status.
+	(ggc_mark_struct_function): Mark f->machine.  Call
+	mark_machine_status only on non-NULL pointers.
+	* system.h: Poison free_machine_status.
+	* config/xtensa/xtensa.c (xtensa_init_machine_status): Use GC on
+	struct machine_function.
+	(xtensa_free_machine_status): Delete.
+	(override_options): Don't set free_machine_status.
+	* config/rs6000/rs6000.c (rs6000_override_options): Don't set
+	free_machine_status.
+	(rs6000_init_machine_status): Use GC on struct machine_function.
+	(rs6000_free_machine_status): Delete.
+	* config/ia64/ia64.c (ia64_init_machine_status): Use GC on struct
+	machine_function.
+	(ia64_mark_machine_status): Likewise.
+	(ia64_free_machine_status): Delete.
+	(ia64_override_options): Don't set free_machine_status.
+	* config/i386/i386.c (override_options): Don't set
+	free_machine_status.
+	(ix86_init_machine_status): Use GC on struct machine_function.
+	(ix86_mark_machine_status): Likewise.
+	(ix86_free_machine_status): Delete.
+	* config/d30v/d30v.c: (d30v_init_machine_status): Use GC on struct
+	machine_function.
+	(d30v_mark_machine_status): Likewise.
+	(d30v_free_machine_status): Delete.
+	(d30v_init_expanders): Don't set free_machine_status.
+	* config/arm/arm.c (arm_mark_machine_status): Use GC on struct
+	machine_function.
+	(arm_init_machine_status): Likewise.
+	(arm_free_machine_status): Delete.
+	(arm_init_expanders): Don't set free_machine_status.
+	* config/alpha/alpha.c (override_options): Don't set
+	free_machine_status.
+	(alpha_init_machine_status): Use GC on struct machine_function.
+	(alpha_mark_machine_status): Likewise.
+	(alpha_free_machine_status): Delete.
+
 	* varasm.c: Don't include obstack.h.
 	(struct varasm_status): x_const_rtx_hash_table is a hash of rtxes.
 	(struct rtx_const): Give substructures names, improve formatting.
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.286.4.1
diff -p -u -p -r1.286.4.1 c-common.c
--- c-common.c	2002/02/13 23:34:51	1.286.4.1
+++ c-common.c	2002/02/19 02:43:53
@@ -3438,6 +3438,7 @@ mark_c_language_function (f)
   if (!f)
     return;
 
+  ggc_mark (f);
   mark_stmt_tree (&f->x_stmt_tree);
   ggc_mark_tree (f->x_scope_stmt_stack);
 }
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.288.2.1
diff -p -u -p -r1.288.2.1 c-decl.c
--- c-decl.c	2002/02/13 23:34:52	1.288.2.1
+++ c-decl.c	2002/02/19 02:43:55
@@ -7236,7 +7236,7 @@ push_c_function_context (f)
 {
   struct c_language_function *p;
   p = ((struct c_language_function *)
-       xmalloc (sizeof (struct c_language_function)));
+       ggc_alloc (sizeof (struct c_language_function)));
   f->language = (struct language_function *) p;
 
   p->base.x_stmt_tree = c_stmt_tree;
@@ -7288,8 +7288,7 @@ pop_c_function_context (f)
   current_extern_inline = p->extern_inline;
   current_binding_level = p->binding_level;
 
-  free (p);
-  f->language = 0;
+  f->language = NULL;
 }
 
 /* Mark the language specific parts of F for GC.  */
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.341.4.4
diff -p -u -p -r1.341.4.4 function.c
--- function.c	2002/02/18 17:14:33	1.341.4.4
+++ function.c	2002/02/19 02:43:57
@@ -123,10 +123,9 @@ int current_function_uses_only_leaf_regs
    post-instantiation libcalls.  */
 int virtuals_instantiated;
 
-/* These variables hold pointers to functions to create and destroy
+/* These variables hold pointers to functions to create
    target specific, per-function data structures.  */
 void (*init_machine_status) PARAMS ((struct function *));
-void (*free_machine_status) PARAMS ((struct function *));
 /* This variable holds a pointer to a function to register any
    data items in the target specific, per-function data structure
    that will need garbage collection.  */
@@ -137,6 +136,7 @@ void (*init_lang_status) PARAMS ((struct
 void (*save_lang_status) PARAMS ((struct function *));
 void (*restore_lang_status) PARAMS ((struct function *));
 void (*mark_lang_status) PARAMS ((struct function *));
+/* This is obsolete; do not set it.  */
 void (*free_lang_status) PARAMS ((struct function *));
 
 /* The FUNCTION_DECL for an inline function currently being expanded.  */
@@ -439,10 +439,8 @@ free_after_compilation (f)
   f->expr = NULL;
   f->emit = NULL;
   f->varasm = NULL;
+  f->machine = NULL;
 
-  if (free_machine_status)
-    (*free_machine_status) (f);
-
   f->x_temp_slots = NULL;
   f->arg_offset_rtx = NULL;
   f->return_rtx = NULL;
@@ -7928,8 +7926,12 @@ ggc_mark_struct_function (f)
   mark_emit_status (f->emit);
   mark_varasm_status (f->varasm);
 
-  if (mark_machine_status)
-    (*mark_machine_status) (f);
+  if (f->machine)
+    {
+      ggc_mark (f->machine);
+      if (mark_machine_status)
+	(*mark_machine_status) (f);
+    }
   if (mark_lang_status)
     (*mark_lang_status) (f);
 
Index: function.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.h,v
retrieving revision 1.75.4.3
diff -p -u -p -r1.75.4.3 function.h
--- function.h	2002/02/18 17:14:34	1.75.4.3
+++ function.h	2002/02/19 02:43:58
@@ -564,10 +564,9 @@ extern HOST_WIDE_INT get_frame_size	PARA
 /* Likewise, but for a different than the current function.  */
 extern HOST_WIDE_INT get_func_frame_size	PARAMS ((struct function *));
 
-/* These variables hold pointers to functions to create and destroy
+/* These variables hold pointers to functions to create
    target specific, per-function data structures.  */
 extern void (*init_machine_status)	PARAMS ((struct function *));
-extern void (*free_machine_status)	PARAMS ((struct function *));
 /* This variable holds a pointer to a function to register any
    data items in the target specific, per-function data structure
    that will need garbage collection.  */
@@ -578,6 +577,7 @@ extern void (*init_lang_status)         
 extern void (*mark_lang_status)		PARAMS ((struct function *));
 extern void (*save_lang_status)		PARAMS ((struct function *));
 extern void (*restore_lang_status)	PARAMS ((struct function *));
+/* This is obsolete.  Do not set it.  */
 extern void (*free_lang_status)         PARAMS ((struct function *));
 
 /* Save and restore status information for a nested function.  */
Index: system.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/system.h,v
retrieving revision 1.113.2.1
diff -p -u -p -r1.113.2.1 system.h
--- system.h	2002/02/13 23:35:40	1.113.2.1
+++ system.h	2002/02/19 02:43:58
@@ -605,7 +605,7 @@ typedef char _Bool;
 	OMIT_EH_TABLE EASY_DIV_EXPR IMPLICIT_FIX_EXPR			   \
 	LONGJMP_RESTORE_FROM_STACK MAX_INT_TYPE_SIZE ASM_IDENTIFY_GCC	   \
 	STDC_VALUE TRAMPOLINE_ALIGN ASM_IDENTIFY_GCC_AFTER_SOURCE	   \
-	SLOW_ZERO_EXTEND SUBREG_REGNO_OFFSET
+	SLOW_ZERO_EXTEND SUBREG_REGNO_OFFSET free_machine_status
 
 #endif /* IN_GCC */
 
Index: config/alpha/alpha.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/alpha.c,v
retrieving revision 1.224.2.1
diff -p -u -p -r1.224.2.1 alpha.c
--- alpha.c	2002/02/13 23:35:56	1.224.2.1
+++ alpha.c	2002/02/19 02:48:12
@@ -167,8 +167,6 @@ static void alpha_init_machine_status
   PARAMS ((struct function *p));
 static void alpha_mark_machine_status
   PARAMS ((struct function *p));
-static void alpha_free_machine_status
-  PARAMS ((struct function *p));
 #endif
 
 static void unicosmk_output_deferred_case_vectors PARAMS ((FILE *));
@@ -501,7 +499,6 @@ override_options ()
   /* Set up function hooks.  */
   init_machine_status = alpha_init_machine_status;
   mark_machine_status = alpha_mark_machine_status;
-  free_machine_status = alpha_free_machine_status;
 #endif
 }
 
@@ -4934,8 +4931,8 @@ static void
 alpha_init_machine_status (p)
      struct function *p;
 {
-  p->machine =
-    (struct machine_function *) xcalloc (1, sizeof (struct machine_function));
+  p->machine = ((struct machine_function *) 
+		ggc_alloc_cleared (sizeof (struct machine_function)));
 
   p->machine->first_ciw = NULL_RTX;
   p->machine->last_ciw = NULL_RTX;
@@ -4949,19 +4946,8 @@ alpha_mark_machine_status (p)
 {
   struct machine_function *machine = p->machine;
 
-  if (machine)
-    {
-      ggc_mark_rtx (machine->first_ciw);
-      ggc_mark_rtx (machine->addr_list);
-    }
-}
-
-static void
-alpha_free_machine_status (p)
-     struct function *p;
-{
-  free (p->machine);
-  p->machine = NULL;
+  ggc_mark_rtx (machine->first_ciw);
+  ggc_mark_rtx (machine->addr_list);
 }
 #endif /* TARGET_ABI_UNICOSMK */
 
Index: config/arm/arm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.184.2.1
diff -p -u -p -r1.184.2.1 arm.c
--- arm.c	2002/02/13 23:35:57	1.184.2.1
+++ arm.c	2002/02/19 02:48:24
@@ -84,7 +84,6 @@ static Mmode     select_dominance_cc_mod
 static Ccstar    shift_op			PARAMS ((rtx, Hint *));
 static void      arm_init_machine_status	PARAMS ((struct function *));
 static void      arm_mark_machine_status        PARAMS ((struct function *));
-static void      arm_free_machine_status        PARAMS ((struct function *));
 static int       number_of_first_bit_set        PARAMS ((int));
 static void      replace_symbols_in_block       PARAMS ((tree, rtx, rtx));
 static void      thumb_exit                     PARAMS ((FILE *, int, rtx));
@@ -10051,8 +10050,7 @@ arm_mark_machine_status (p)
 {
   machine_function *machine = p->machine;
 
-  if (machine)
-    ggc_mark_rtx (machine->eh_epilogue_sp_ofs);
+  ggc_mark_rtx (machine->eh_epilogue_sp_ofs);
 }
 
 static void
@@ -10060,24 +10058,13 @@ arm_init_machine_status (p)
      struct function * p;
 {
   p->machine =
-    (machine_function *) xcalloc (1, sizeof (machine_function));
+    (machine_function *) ggc_alloc_cleared (sizeof (machine_function));
 
 #if ARM_FT_UNKNOWWN != 0  
   ((machine_function *) p->machine)->func_type = ARM_FT_UNKNOWN;
 #endif
 }
 
-static void
-arm_free_machine_status (p)
-     struct function * p;
-{
-  if (p->machine)
-    {
-      free (p->machine);
-      p->machine = NULL;
-    }
-}
-
 /* Return an RTX indicating where the return address to the
    calling function can be found.  */
 
@@ -10107,7 +10094,6 @@ arm_init_expanders ()
   /* Arrange to initialize and mark the machine per-function status.  */
   init_machine_status = arm_init_machine_status;
   mark_machine_status = arm_mark_machine_status;
-  free_machine_status = arm_free_machine_status;
 }
 
 /* Generate the rest of a function's prologue.  */
Index: config/d30v/d30v.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/d30v/d30v.c,v
retrieving revision 1.20
diff -p -u -p -r1.20 d30v.c
--- d30v.c	2002/01/03 17:40:00	1.20
+++ d30v.c	2002/02/19 02:48:46
@@ -49,7 +49,6 @@ static void d30v_build_long_insn PARAMS 
 static void d30v_add_gc_roots PARAMS ((void));
 static void d30v_init_machine_status PARAMS ((struct function *));
 static void d30v_mark_machine_status PARAMS ((struct function *));
-static void d30v_free_machine_status PARAMS ((struct function *));
 static void d30v_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
 static void d30v_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
 static int d30v_adjust_cost PARAMS ((rtx, rtx, rtx, int));
@@ -3548,32 +3547,16 @@ d30v_init_machine_status (p)
      struct function *p;
 {
   p->machine =
-    (machine_function *) xcalloc (1, sizeof (machine_function));
+    (machine_function *) ggc_alloc_cleared (sizeof (machine_function));
 }
 
 static void
 d30v_mark_machine_status (p)
      struct function * p;
 {
-  if (p->machine == NULL)
-    return;
-  
   ggc_mark_rtx (p->machine->eh_epilogue_sp_ofs);
 }
 
-static void
-d30v_free_machine_status (p)
-     struct function *p;
-{
-  struct machine_function *machine = p->machine;
-
-  if (machine == NULL)
-    return;
-
-  free (machine);
-  p->machine = NULL;
-}
-
 /* Do anything needed before RTL is emitted for each function.  */
 
 void
@@ -3582,7 +3565,6 @@ d30v_init_expanders ()
   /* Arrange to save and restore machine status around nested functions.  */
   init_machine_status = d30v_init_machine_status;
   mark_machine_status = d30v_mark_machine_status;
-  free_machine_status = d30v_free_machine_status;
 }
 
 /* Find the current function's return address.
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.357.2.1
diff -p -u -p -r1.357.2.1 i386.c
--- i386.c	2002/02/13 23:36:09	1.357.2.1
+++ i386.c	2002/02/19 02:49:04
@@ -665,7 +665,6 @@ static rtx * ix86_pent_find_pair PARAMS 
 					 rtx));
 static void ix86_init_machine_status PARAMS ((struct function *));
 static void ix86_mark_machine_status PARAMS ((struct function *));
-static void ix86_free_machine_status PARAMS ((struct function *));
 static int ix86_split_to_parts PARAMS ((rtx, rtx *, enum machine_mode));
 static int ix86_safe_length_prefix PARAMS ((rtx));
 static int ix86_nsaved_regs PARAMS ((void));
@@ -1007,7 +1006,6 @@ override_options ()
   /* Arrange to set up i386_stack_locals for all functions.  */
   init_machine_status = ix86_init_machine_status;
   mark_machine_status = ix86_mark_machine_status;
-  free_machine_status = ix86_free_machine_status;
 
   /* Validate -mregparm= value.  */
   if (ix86_regparm_string)
@@ -9624,7 +9622,7 @@ ix86_init_machine_status (p)
      struct function *p;
 {
   p->machine = (struct machine_function *)
-    xcalloc (1, sizeof (struct machine_function));
+    ggc_alloc_cleared (sizeof (struct machine_function));
 }
 
 /* Mark machine specific bits of P for GC.  */
@@ -9636,21 +9634,10 @@ ix86_mark_machine_status (p)
   enum machine_mode mode;
   int n;
 
-  if (! machine)
-    return;
-
   for (mode = VOIDmode; (int) mode < (int) MAX_MACHINE_MODE;
        mode = (enum machine_mode) ((int) mode + 1))
     for (n = 0; n < MAX_386_STACK_LOCALS; n++)
       ggc_mark_rtx (machine->stack_locals[(int) mode][n]);
-}
-
-static void
-ix86_free_machine_status (p)
-     struct function *p;
-{
-  free (p->machine);
-  p->machine = NULL;
 }
 
 /* Return a MEM corresponding to a stack slot with mode MODE.
Index: config/ia64/ia64.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/ia64/ia64.c,v
retrieving revision 1.137.6.1
diff -p -u -p -r1.137.6.1 ia64.c
--- ia64.c	2002/02/13 23:36:11	1.137.6.1
+++ ia64.c	2002/02/19 02:49:24
@@ -122,7 +122,6 @@ static void fix_range PARAMS ((const cha
 static void ia64_add_gc_roots PARAMS ((void));
 static void ia64_init_machine_status PARAMS ((struct function *));
 static void ia64_mark_machine_status PARAMS ((struct function *));
-static void ia64_free_machine_status PARAMS ((struct function *));
 static void emit_insn_group_barriers PARAMS ((FILE *, rtx));
 static void emit_all_insn_group_barriers PARAMS ((FILE *, rtx));
 static void emit_predicate_relation_info PARAMS ((void));
@@ -3897,8 +3896,8 @@ static void
 ia64_init_machine_status (p)
      struct function *p;
 {
-  p->machine =
-    (struct machine_function *) xcalloc (1, sizeof (struct machine_function));
+  p->machine = ((struct machine_function *) 
+		ggc_alloc_cleared (sizeof (struct machine_function)));
 }
 
 static void
@@ -3907,20 +3906,9 @@ ia64_mark_machine_status (p)
 {
   struct machine_function *machine = p->machine;
 
-  if (machine)
-    {
-      ggc_mark_rtx (machine->ia64_eh_epilogue_sp);
-      ggc_mark_rtx (machine->ia64_eh_epilogue_bsp);
-      ggc_mark_rtx (machine->ia64_gp_save);
-    }
-}
-
-static void
-ia64_free_machine_status (p)
-     struct function *p;
-{
-  free (p->machine);
-  p->machine = NULL;
+  ggc_mark_rtx (machine->ia64_eh_epilogue_sp);
+  ggc_mark_rtx (machine->ia64_eh_epilogue_bsp);
+  ggc_mark_rtx (machine->ia64_gp_save);
 }
 
 /* Handle TARGET_OPTIONS switches.  */
@@ -3947,7 +3935,6 @@ ia64_override_options ()
 
   init_machine_status = ia64_init_machine_status;
   mark_machine_status = ia64_mark_machine_status;
-  free_machine_status = ia64_free_machine_status;
 
   ia64_add_gc_roots ();
 }
Index: config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.278.2.1
diff -p -u -p -r1.278.2.1 rs6000.c
--- rs6000.c	2002/02/13 23:36:18	1.278.2.1
+++ rs6000.c	2002/02/19 02:50:18
@@ -134,7 +134,6 @@ static int toc_hash_eq PARAMS ((const vo
 static int toc_hash_mark_entry PARAMS ((void **, void *));
 static void toc_hash_mark_table PARAMS ((void *));
 static int constant_pool_expr_1 PARAMS ((rtx, int *, int *));
-static void rs6000_free_machine_status PARAMS ((struct function *));
 static void rs6000_init_machine_status PARAMS ((struct function *));
 static bool rs6000_assemble_integer PARAMS ((rtx, unsigned int, int));
 static int rs6000_ra_ever_killed PARAMS ((void));
@@ -577,7 +576,6 @@ rs6000_override_options (default_cpu)
 
   /* Arrange to save and restore machine status around nested functions.  */
   init_machine_status = rs6000_init_machine_status;
-  free_machine_status = rs6000_free_machine_status;
 }
 
 /* Handle -mabi= options.  */
@@ -6065,20 +6063,9 @@ static void
 rs6000_init_machine_status (p)
      struct function *p;
 {
-  p->machine = (machine_function *) xcalloc (1, sizeof (machine_function));
+  p->machine = ((machine_function *) 
+		ggc_alloc_cleared (sizeof (machine_function)));
 }
-
-static void
-rs6000_free_machine_status (p)
-     struct function *p;
-{
-  if (p->machine == NULL)
-    return;
-
-  free (p->machine);
-  p->machine = NULL;
-}
-
 
 /* Print an operand.  Recognize special options, documented below.  */
 
Index: config/xtensa/xtensa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/xtensa/xtensa.c,v
retrieving revision 1.1.6.1
diff -p -u -p -r1.1.6.1 xtensa.c
--- xtensa.c	2002/02/14 00:34:47	1.1.6.1
+++ xtensa.c	2002/02/19 02:50:56
@@ -220,7 +220,6 @@ static rtx gen_conditional_move PARAMS (
 static rtx fixup_subreg_mem PARAMS ((rtx x));
 static enum machine_mode xtensa_find_mode_for_size PARAMS ((unsigned));
 static void xtensa_init_machine_status PARAMS ((struct function *p));
-static void xtensa_free_machine_status PARAMS ((struct function *p));
 static void printx PARAMS ((FILE *, signed int));
 static rtx frame_size_const;
 static int current_function_arg_words;
@@ -1525,19 +1524,10 @@ xtensa_init_machine_status (p)
      struct function *p;
 {
   p->machine = (struct machine_function *)
-    xcalloc (1, sizeof (struct machine_function));
+    ggc_alloc_cleared (1, sizeof (struct machine_function));
 }
 
 
-static void
-xtensa_free_machine_status (p)
-     struct function *p;
-{
-  free (p->machine);
-  p->machine = NULL;
-}
-
-
 void
 xtensa_setup_frame_addresses ()
 {
@@ -1817,7 +1807,6 @@ override_options ()
     }
 
   init_machine_status = xtensa_init_machine_status;
-  free_machine_status = xtensa_free_machine_status;
 
   /* Check PIC settings.  There's no need for -fPIC on Xtensa and
      some targets need to always use PIC.  */
Index: cp/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/ChangeLog,v
retrieving revision 1.2639.2.1
diff -p -u -p -r1.2639.2.1 ChangeLog
--- ChangeLog	2002/02/13 23:36:25	1.2639.2.1
+++ ChangeLog	2002/02/19 02:51:01
@@ -1,3 +1,12 @@
+2002-02-18  Geoffrey Keating  <geoffk@redhat.com>
+
+	* decl.c (start_function): Don't free 'struct
+	cp_language_function'.
+	(pop_cp_function_context): Likewise.
+	(save_function_data): Allocate it using GC.
+	* semantics.c (genrtl_start_function): Don't free 'struct
+	cp_language_function'.
+
 2002-02-11  Jason Merrill  <jason@redhat.com>
 
 	* parse.y (reserved_declspecs): Don't handle attributes.
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.847.2.1
diff -p -u -p -r1.847.2.1 decl.c
--- decl.c	2002/02/13 23:36:29	1.847.2.1
+++ decl.c	2002/02/19 02:51:26
@@ -13664,12 +13664,8 @@ start_function (declspecs, declarator, a
 
   /* If we are (erroneously) defining a function that we have already
      defined before, wipe out what we knew before.  */
-  if (!DECL_PENDING_INLINE_P (decl1)
-      && DECL_SAVED_FUNCTION_DATA (decl1))
-    {
-      free (DECL_SAVED_FUNCTION_DATA (decl1));
-      DECL_SAVED_FUNCTION_DATA (decl1) = NULL;
-    }
+  if (!DECL_PENDING_INLINE_P (decl1))
+    DECL_SAVED_FUNCTION_DATA (decl1) = NULL;
 
   if (ctype && !doing_friend && !DECL_STATIC_FUNCTION_P (decl1))
     {
@@ -13887,7 +13883,7 @@ save_function_data (decl)
 
   /* Make a copy.  */
   f = ((struct cp_language_function *)
-       xmalloc (sizeof (struct cp_language_function)));
+       ggc_alloc (sizeof (struct cp_language_function)));
   memcpy (f, cp_function_chain, sizeof (struct cp_language_function));
   DECL_SAVED_FUNCTION_DATA (decl) = f;
 
@@ -14566,7 +14562,7 @@ push_cp_function_context (f)
 {
   struct cp_language_function *p
     = ((struct cp_language_function *)
-       xcalloc (1, sizeof (struct cp_language_function)));
+       ggc_alloc_cleared (sizeof (struct cp_language_function)));
   f->language = (struct language_function *) p;
 
   /* It takes an explicit call to expand_body to generate RTL for a
@@ -14591,7 +14587,6 @@ pop_cp_function_context (f)
 	(struct cp_language_function *) f->language;
       if (cp->x_local_names)
 	VARRAY_FREE (cp->x_local_names);
-      free (f->language);
     }
   f->language = 0;
 }
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.244.2.1
diff -p -u -p -r1.244.2.1 semantics.c
--- semantics.c	2002/02/13 23:36:32	1.244.2.1
+++ semantics.c	2002/02/19 02:51:39
@@ -2525,7 +2525,6 @@ genrtl_start_function (fn)
 	current_function_cannot_inline = cp_function_chain->cannot_inline;
 
       /* We don't need the saved data anymore.  */
-      free (DECL_SAVED_FUNCTION_DATA (fn));
       DECL_SAVED_FUNCTION_DATA (fn) = NULL;
     }
 
Index: doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.88.2.1
diff -p -u -p -r1.88.2.1 tm.texi
--- tm.texi	2002/02/13 23:36:34	1.88.2.1
+++ tm.texi	2002/02/19 02:52:04
@@ -807,8 +807,8 @@ to their own specific data.
 If a target needs per-function specific data it should define the type
 @code{struct machine_function} and also the macro
 @code{INIT_EXPANDERS}.  This macro should be used to initialize some or
-all of the function pointers @code{init_machine_status},
-@code{free_machine_status} and @code{mark_machine_status}.  These
+all of the function pointers @code{init_machine_status}
+and @code{mark_machine_status}.  These
 pointers are explained below.
 
 One typical use of per-function, target specific data is to create an
@@ -845,19 +845,18 @@ specific initialization of the @code{str
 intended that this would be used to initialize the @code{machine} of
 that structure.
 
-@findex free_machine_status
-@item   free_machine_status
-This is a @code{void (*)(struct function *)} function pointer.  If this
-pointer is non-@code{NULL} it will be called once per function, after the
-function has been compiled, in order to allow any memory allocated
-during the @code{init_machine_status} function call to be freed.
+@code{struct machine_function} structures are expected to be freed by GC.
+Generally, any memory that they reference must be allocated by using
+@code{ggc_alloc}, including the structure itself.
 
 @findex mark_machine_status
 @item   mark_machine_status
 This is a @code{void (*)(struct function *)} function pointer.  If this
-pointer is non-@code{NULL} it will be called once per function in order to mark
-any data items in the @code{struct machine_function} structure which
-need garbage collection.
+pointer is non-@code{NULL} it will be called once per function in order
+to mark any data items in the @code{struct machine_function} structure
+which need garbage collection.  It will not be called if @code{machine}
+of the function structure is @code{NULL}.  It need not mark
+its argument.
 
 @end table
 
============================================================


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