This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Save GGC garbage produced by gimplifier
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org, rth at redhat dot com
- Date: Thu, 2 Sep 2004 17:25:33 +0200
- Subject: Save GGC garbage produced by gimplifier
Hi,
the memory usage of varrays increased dramatically since 3.4 accounting now
about 20% of memory overhead. About 60% of it (at -O0) accounts to varray
"stack" used by gimplifier that needs not to live in ggc at all.
Bootstrapped/regtessed on i686-pc-gnu-linux.
I don't like the need to use GENERIC_PTR for trees. An alternative is
to add explicit ggc_free to release the varray that looks slightly
inferrior because of the fragmentation, but if it is preffered, I can do
that too.
Honza
* gimplify.c (gimplify_compound_lval): Move "stack" varray out of
GGC.
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v
retrieving revision 1.1.2.141.2.9
diff -c -3 -p -r1.1.2.141.2.9 gimplify.c
*** gimplify.c 2 Aug 2004 23:11:48 -0000 1.1.2.141.2.9
--- gimplify.c 1 Sep 2004 19:59:58 -0000
*************** gimplify_compound_lval (tree *expr_p, tr
*** 1510,1517 ****
int i;
/* Create a stack of the subexpressions so later we can walk them in
! order from inner to outer. */
! VARRAY_TREE_INIT (stack, 10, "stack");
/* We can either handle REALPART_EXPR, IMAGEPART_EXPR anything that
handled_components can deal with. */
--- 1510,1520 ----
int i;
/* Create a stack of the subexpressions so later we can walk them in
! order from inner to outer.
!
! This array is very memory consuming. Don't even think of making
! it VARRAY_TREE. */
! VARRAY_GENERIC_PTR_NOGC_INIT (stack, 10, "stack");
/* We can either handle REALPART_EXPR, IMAGEPART_EXPR anything that
handled_components can deal with. */
*************** gimplify_compound_lval (tree *expr_p, tr
*** 1519,1525 ****
(handled_component_p (*p)
|| TREE_CODE (*p) == REALPART_EXPR || TREE_CODE (*p) == IMAGPART_EXPR);
p = &TREE_OPERAND (*p, 0))
! VARRAY_PUSH_TREE (stack, *p);
#if defined ENABLE_CHECKING
if (VARRAY_ACTIVE_SIZE (stack) == 0)
--- 1522,1528 ----
(handled_component_p (*p)
|| TREE_CODE (*p) == REALPART_EXPR || TREE_CODE (*p) == IMAGPART_EXPR);
p = &TREE_OPERAND (*p, 0))
! VARRAY_PUSH_GENERIC_PTR_NOGC (stack, *p);
#if defined ENABLE_CHECKING
if (VARRAY_ACTIVE_SIZE (stack) == 0)
*************** gimplify_compound_lval (tree *expr_p, tr
*** 1540,1546 ****
then we gimplify any indices, from left to right. */
for (i = VARRAY_ACTIVE_SIZE (stack) - 1; i >= 0; i--)
{
! tree t = VARRAY_TREE (stack, i);
if (TREE_CODE (t) == ARRAY_REF || TREE_CODE (t) == ARRAY_RANGE_REF)
{
--- 1543,1549 ----
then we gimplify any indices, from left to right. */
for (i = VARRAY_ACTIVE_SIZE (stack) - 1; i >= 0; i--)
{
! tree t = VARRAY_GENERIC_PTR_NOGC (stack, i);
if (TREE_CODE (t) == ARRAY_REF || TREE_CODE (t) == ARRAY_RANGE_REF)
{
*************** gimplify_compound_lval (tree *expr_p, tr
*** 1659,1664 ****
--- 1662,1669 ----
ret = MIN (ret, GS_OK);
}
+ VARRAY_FREE (stack);
+
return ret;
}