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]

Re: RFA: make reg_equiv_memory_loc visible to garbage collector


...
>             I think you should try making the gengtype change.
...
>                                                   The new gcc-2.x
> init_reload function has always been called once, along with all of the
> other once-per-compile backend initialization functions.  It is safe to
> put the reg_equiv_memory_loc_varray call here.

Ok, I have made these changes, and also amended the comment in reload.c .

2004-05-19  J"orn Rennecke <joern.rennecke@superh.com>

	* Makefile.in (reload1.o): Depend on gt-reload.h.
	(GTFILES): Add $(srcdir)/reload.h.
	(gt-reload.h): Depend on s-gtype.
	* gengtype.c (open_base_files): Include reload.h in ifiles.
	* reload.h (reg_equiv_memory_loc_varray): Declare.
	* reload1.c (reg_equiv_memory_loc_varray): New variable.
	(init_reload): Initialize it.
	(reload): Instead of freeing reg_equiv_memory_loc, 'grow'
	("gt-reload.h"): Include.
	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.
	* reload.c: Amend comment on calling init_reload.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1275
diff -p -r1.1275 Makefile.in
*** Makefile.in	13 May 2004 06:39:25 -0000	1.1275
--- Makefile.in	19 May 2004 16:30:48 -0000
*************** reload.o : reload.c $(CONFIG_H) $(SYSTEM
*** 1969,1975 ****
  reload1.o : reload1.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) real.h flags.h \
     $(EXPR_H) $(OPTABS_H) reload.h $(REGS_H) hard-reg-set.h insn-config.h \
     $(BASIC_BLOCK_H) $(RECOG_H) output.h function.h toplev.h $(TM_P_H) \
!    except.h $(TREE_H)
  postreload.o : postreload.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) real.h flags.h \
     $(EXPR_H) $(OPTABS_H) reload.h $(REGS_H) hard-reg-set.h insn-config.h \
     $(BASIC_BLOCK_H) $(RECOG_H) output.h function.h toplev.h cselib.h $(TM_P_H) \
--- 1969,1975 ----
  reload1.o : reload1.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) real.h flags.h \
     $(EXPR_H) $(OPTABS_H) reload.h $(REGS_H) hard-reg-set.h insn-config.h \
     $(BASIC_BLOCK_H) $(RECOG_H) output.h function.h toplev.h $(TM_P_H) \
!    except.h $(TREE_H) gt-reload.h
  postreload.o : postreload.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) real.h flags.h \
     $(EXPR_H) $(OPTABS_H) reload.h $(REGS_H) hard-reg-set.h insn-config.h \
     $(BASIC_BLOCK_H) $(RECOG_H) output.h function.h toplev.h cselib.h $(TM_P_H) \
*************** GTFILES = $(srcdir)/input.h $(srcdir)/co
*** 2265,2271 ****
    $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/libfuncs.h $(srcdir)/hashtable.h \
    $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \
    $(srcdir)/cselib.h $(srcdir)/basic-block.h  $(srcdir)/cgraph.h \
!   $(srcdir)/c-common.h $(srcdir)/c-tree.h \
    $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
    $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
    $(srcdir)/dojump.c \
--- 2265,2271 ----
    $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/libfuncs.h $(srcdir)/hashtable.h \
    $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \
    $(srcdir)/cselib.h $(srcdir)/basic-block.h  $(srcdir)/cgraph.h \
!   $(srcdir)/c-common.h $(srcdir)/c-tree.h $(srcdir)/reload.h \
    $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
    $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
    $(srcdir)/dojump.c \
*************** gt-tree-alias-common.h gt-tree-mudflap.h
*** 2306,2312 ****
  gt-tree-ssa-ccp.h gt-tree-eh.h \
  gt-tree-ssanames.h gt-tree-iterator.h gt-gimplify.h \
  gt-tree-phinodes.h gt-tree-cfg.h gt-tree-nested.h \
! gt-stringpool.h gt-langhooks.h : s-gtype ; @true
  
  gtyp-gen.h: s-gtyp-gen ; @true
  s-gtyp-gen: Makefile
--- 2306,2312 ----
  gt-tree-ssa-ccp.h gt-tree-eh.h \
  gt-tree-ssanames.h gt-tree-iterator.h gt-gimplify.h \
  gt-tree-phinodes.h gt-tree-cfg.h gt-tree-nested.h \
! gt-stringpool.h gt-langhooks.h gt-reload.h : s-gtype ; @true
  
  gtyp-gen.h: s-gtyp-gen ; @true
  s-gtyp-gen: Makefile
Index: gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype.c,v
retrieving revision 1.48
diff -p -r1.48 gengtype.c
*** gengtype.c	13 May 2004 06:39:42 -0000	1.48
--- gengtype.c	19 May 2004 16:30:48 -0000
*************** open_base_files (void)
*** 1100,1106 ****
        "function.h", "insn-config.h", "expr.h", "hard-reg-set.h",
        "basic-block.h", "cselib.h", "insn-addr.h", "optabs.h",
        "libfuncs.h", "debug.h", "ggc.h", "cgraph.h",
!       "tree-alias-type.h", "tree-flow.h",
        NULL
      };
      const char *const *ifp;
--- 1100,1106 ----
        "function.h", "insn-config.h", "expr.h", "hard-reg-set.h",
        "basic-block.h", "cselib.h", "insn-addr.h", "optabs.h",
        "libfuncs.h", "debug.h", "ggc.h", "cgraph.h",
!       "tree-alias-type.h", "tree-flow.h", "reload.h",
        NULL
      };
      const char *const *ifp;
Index: passes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/passes.c,v
retrieving revision 2.12
diff -p -r2.12 passes.c
*** passes.c	13 May 2004 06:39:44 -0000	2.12
--- passes.c	19 May 2004 16:30:49 -0000
*************** rest_of_handle_old_regalloc (tree decl, 
*** 624,630 ****
    allocate_reg_info (max_regno, FALSE, TRUE);
  
    /* And the reg_equiv_memory_loc array.  */
!   reg_equiv_memory_loc = xcalloc (max_regno, sizeof (rtx));
  
    allocate_initial_values (reg_equiv_memory_loc);
  
--- 624,631 ----
    allocate_reg_info (max_regno, FALSE, TRUE);
  
    /* And the reg_equiv_memory_loc array.  */
!   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: ra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra.c,v
retrieving revision 1.16
diff -p -r1.16 ra.c
*** ra.c	24 Feb 2004 23:39:56 -0000	1.16
--- ra.c	19 May 2004 16:30:49 -0000
*************** reg_alloc (void)
*** 887,893 ****
  			 "after allocation/spilling, before reload", NULL);
  
    /* Allocate the reg_equiv_memory_loc array for reload.  */
!   reg_equiv_memory_loc = xcalloc (max_regno, sizeof (rtx));
    /* And possibly initialize it.  */
    allocate_initial_values (reg_equiv_memory_loc);
    /* And one last regclass pass just before reload.  */
--- 887,894 ----
  			 "after allocation/spilling, before reload", NULL);
  
    /* Allocate the reg_equiv_memory_loc array for reload.  */
!   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: reload.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload.c,v
retrieving revision 1.241
diff -p -r1.241 reload.c
*** reload.c	13 May 2004 06:39:45 -0000	1.241
--- reload.c	19 May 2004 16:30:51 -0000
*************** Software Foundation, 59 Temple Place - S
*** 27,32 ****
--- 27,33 ----
     ought to be used instead.
  
     Before processing the first insn of the function, call `init_reload'.
+    init_reload actually has to be called earlier anyway.
  
     To scan an insn, call `find_reloads'.  This does two things:
     1. sets up tables describing which values must be reloaded
Index: reload.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload.h,v
retrieving revision 1.45
diff -p -r1.45 reload.h
*** reload.h	6 Jul 2003 09:56:07 -0000	1.45
--- reload.h	19 May 2004 16:30:51 -0000
*************** extern struct reload rld[MAX_RELOADS];
*** 164,169 ****
--- 164,170 ----
  extern int n_reloads;
  #endif
  
+ extern GTY (()) struct varray_head_tag *reg_equiv_memory_loc_varray;
  extern rtx *reg_equiv_constant;
  extern rtx *reg_equiv_memory_loc;
  extern rtx *reg_equiv_address;
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.435
diff -p -r1.435 reload1.c
*** reload1.c	6 May 2004 03:24:49 -0000	1.435
--- reload1.c	19 May 2004 16:30:53 -0000
*************** rtx *reg_equiv_constant;
*** 102,107 ****
--- 102,111 ----
     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.)  */
*************** init_reload (void)
*** 482,487 ****
--- 486,492 ----
  
    INIT_REG_SET (&spilled_pseudos);
    INIT_REG_SET (&pseudos_counted);
+   VARRAY_RTX_INIT (reg_equiv_memory_loc_varray, 0, "reg_equiv_memory_loc");
  }
  
  /* List of insn chains that are currently unused.  */
*************** reload (rtx first, int global)
*** 1236,1243 ****
    if (reg_equiv_constant)
      free (reg_equiv_constant);
    reg_equiv_constant = 0;
!   if (reg_equiv_memory_loc)
!     free (reg_equiv_memory_loc);
    reg_equiv_memory_loc = 0;
  
    if (offsets_known_at)
--- 1241,1247 ----
    if (reg_equiv_constant)
      free (reg_equiv_constant);
    reg_equiv_constant = 0;
!   VARRAY_GROW (reg_equiv_memory_loc_varray, 0);
    reg_equiv_memory_loc = 0;
  
    if (offsets_known_at)
*************** fixup_abnormal_edges (void)
*** 8138,8140 ****
--- 8142,8146 ----
    if (inserted)
      commit_edge_insertions ();
  }
+ 
+ #include "gt-reload.h"


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