This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] replace gcc_alloc_rtx with rtx_alloc
- From: Dan Nicolaescu <dann at godzilla dot ics dot uci dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 01 Sep 2004 18:24:56 -0700
- Subject: [patch] replace gcc_alloc_rtx with rtx_alloc
The rtx memory usage reported by -fmem-report is currently off by a
factor of 3!
This is because the rtx memory allocation stats are done in
rtl.c:rtx_alloc_stat, but gengenrtl.c uses ggc_alloc_rtx, which does
not keep track of memory allocations.
The code synthesized by gengenrtl does the same thing as rtx_alloc
does: allocate memory, clear it and set the rtx code. That code can be
replaced with a rtx_alloc call. After that nothing else uses
ggc_alloc_rtx, so it can be deleted.
Bootstrapped on i686-linux
2004-09-01 Dan Nicolaescu <dann@ics.uci.edu>
* gengenrtl.c (gendef): Use rtx_alloc, don't do PUT_CODE.
* ggc.h (ggc_alloc_rtx): Delete.
Index: ggc.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc.h,v
retrieving revision 1.67
diff -c -3 -p -r1.67 ggc.h
*** ggc.h 25 Jul 2004 00:20:14 -0000 1.67
--- ggc.h 1 Sep 2004 23:43:57 -0000
*************** extern void dump_ggc_loc_statistics (voi
*** 245,253 ****
#define GGC_NEWVAR(T, S) ((T *) ggc_alloc ((S)))
#define GGC_CNEWVAR(T, S) ((T *) ggc_alloc_cleared ((S)))
- #define ggc_alloc_rtx(CODE) \
- ((rtx) ggc_alloc_typed (gt_ggc_e_7rtx_def, RTX_SIZE (CODE)))
-
#define ggc_alloc_rtvec(NELT) \
((rtvec) ggc_alloc_typed (gt_ggc_e_9rtvec_def, sizeof (struct rtvec_def) \
+ ((NELT) - 1) * sizeof (rtx)))
--- 245,250 ----
Index: gengenrtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengenrtl.c,v
retrieving revision 1.66
diff -c -3 -p -r1.66 gengenrtl.c
*** gengenrtl.c 18 Oct 2003 18:45:16 -0000 1.66
--- gengenrtl.c 1 Sep 2004 23:43:57 -0000
*************** gendef (const char *format)
*** 268,277 ****
the memory and initializes it. */
puts ("{");
puts (" rtx rt;");
! puts (" rt = ggc_alloc_rtx (code);\n");
- puts (" memset (rt, 0, RTX_HDR_SIZE);\n");
- puts (" PUT_CODE (rt, code);");
puts (" PUT_MODE (rt, mode);");
for (p = format, i = j = 0; *p ; ++p, ++i)
--- 268,275 ----
the memory and initializes it. */
puts ("{");
puts (" rtx rt;");
! puts (" rt = rtx_alloc (code);\n");
puts (" PUT_MODE (rt, mode);");
for (p = format, i = j = 0; *p ; ++p, ++i)