RFA: make reg_equiv_memory_loc visible to garbage collector (Was: Re: reg_equiv_memory_loc vs. garbage collection)
Joern Rennecke
joern.rennecke@superh.com
Fri May 14 17:00:00 GMT 2004
> This is an SH specific problem, as the SH port is the only one that
> defines the ALLOCATE_INITIAL_VALUE macro. The definition in
> config/sh/sh.h has no comment, so I don't know what it is doing. It
> also turns out that this is code you wrote. So you probably should try
> to fix it yourself.
I'm regression testing this patch now, in mainline from last night + my
scheduler patch from earlier today (because otherwise sh-elf won't build).
2004-05-14 J"orn Rennecke <joern.rennecke@superh.com>
* rtl.h (reg_equiv_memory_loc_varray): Declare.
* reload1.c (reg_equiv_memory_loc_varray): New variable.
(reload): Instead of freeing reg_equiv_memory_loc, 'grow'
reg_equiv_memory_loc_varray to size 0.
* ra.c (reg_alloc): Allocate reg_equiv_memory_loc by
growing reg_equiv_memory_loc_varray to the desired size.
* passes.c (rest_of_handle_old_regalloc): Likewise.
* toplev.c (general_init): initialize reg_equiv_memory_loc_varray.
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.470
diff -p -u -r1.470 rtl.h
--- rtl.h 3 May 2004 01:27:55 -0000 1.470
+++ rtl.h 14 May 2004 16:24:14 -0000
@@ -2445,6 +2445,9 @@ extern int stack_regs_mentioned (rtx ins
/* In toplev.c */
extern GTY(()) rtx stack_limit_rtx;
+/* In reload1.c */
+extern GTY (()) struct varray_head_tag *reg_equiv_memory_loc_varray;
+
/* In regrename.c */
extern void regrename_optimize (void);
extern void copyprop_hardreg_forward (void);
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.434
diff -p -u -r1.434 reload1.c
--- reload1.c 4 May 2004 17:57:30 -0000 1.434
+++ reload1.c 14 May 2004 16:24:15 -0000
@@ -102,6 +102,10 @@ rtx *reg_equiv_constant;
is transferred to either reg_equiv_address or reg_equiv_mem. */
rtx *reg_equiv_memory_loc;
+/* We allocate reg_equiv_memory_loc inside a varray so that the garbage
+ collector can keep track of what is inside. */
+varray_type reg_equiv_memory_loc_varray;
+
/* Element N is the address of stack slot to which pseudo reg N is equivalent.
This is used when the address is not valid as a memory address
(because its displacement is too big for the machine.) */
@@ -1236,8 +1240,7 @@ reload (rtx first, int global)
if (reg_equiv_constant)
free (reg_equiv_constant);
reg_equiv_constant = 0;
- if (reg_equiv_memory_loc)
- free (reg_equiv_memory_loc);
+ VARRAY_GROW (reg_equiv_memory_loc_varray, 0);
reg_equiv_memory_loc = 0;
if (offsets_known_at)
Index: ra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra.c,v
retrieving revision 1.16
diff -p -u -r1.16 ra.c
--- ra.c 24 Feb 2004 23:39:56 -0000 1.16
+++ ra.c 14 May 2004 16:24:15 -0000
@@ -887,7 +887,8 @@ reg_alloc (void)
"after allocation/spilling, before reload", NULL);
/* Allocate the reg_equiv_memory_loc array for reload. */
- reg_equiv_memory_loc = xcalloc (max_regno, sizeof (rtx));
+ VARRAY_GROW (reg_equiv_memory_loc_varray, max_regno);
+ reg_equiv_memory_loc = &VARRAY_RTX (reg_equiv_memory_loc_varray, 0);
/* And possibly initialize it. */
allocate_initial_values (reg_equiv_memory_loc);
/* And one last regclass pass just before reload. */
Index: passes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/passes.c,v
retrieving revision 2.11
diff -p -u -r2.11 passes.c
--- passes.c 5 May 2004 10:52:59 -0000 2.11
+++ passes.c 14 May 2004 16:24:15 -0000
@@ -623,7 +623,8 @@ rest_of_handle_old_regalloc (tree decl,
allocate_reg_info (max_regno, FALSE, TRUE);
/* And the reg_equiv_memory_loc array. */
- reg_equiv_memory_loc = xcalloc (max_regno, sizeof (rtx));
+ VARRAY_GROW (reg_equiv_memory_loc_varray, max_regno);
+ reg_equiv_memory_loc = &VARRAY_RTX (reg_equiv_memory_loc_varray, 0);
allocate_initial_values (reg_equiv_memory_loc);
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.895
diff -p -u -r1.895 toplev.c
--- toplev.c 20 Apr 2004 09:27:41 -0000 1.895
+++ toplev.c 14 May 2004 16:24:15 -0000
@@ -2202,6 +2202,7 @@ general_init (const char *argv0)
/* Initialize the garbage-collector, string pools and tree type hash
table. */
init_ggc ();
+ VARRAY_RTX_INIT (reg_equiv_memory_loc_varray, 0, "reg_equiv_memory_loc");
init_stringpool ();
linemap_init (&line_table);
init_ttree ();
More information about the Gcc
mailing list