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]

Trim down memory usage in alias.c


Hi,
this trick reduces amount of memory allocated by that ggc_alloc call
from 31MB to 800Kb for Gerald's testcase and 256MB system.

Fulltesting is still in progress (I've killed it by accident), OK if it
passes?

Honza

	* alias.c (old_reg_base_value, old_reg_base_value_size): New global variables.
	(init_alias_analysis): Reuse existing array if available.
	
Index: alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/alias.c,v
retrieving revision 1.210
diff -c -3 -p -r1.210 alias.c
*** alias.c	17 Jan 2004 09:31:29 -0000	1.210
--- alias.c	20 Jan 2004 20:32:36 -0000
*************** static GTY((length ("reg_base_value_size
*** 161,166 ****
--- 161,172 ----
  static rtx *new_reg_base_value;
  static unsigned int reg_base_value_size; /* size of reg_base_value array */
  
+ /* We preserve the copy of old array around to avoid amount of garbage
+    produced.  About 8% of garbage produced were attributed to this
+    array.  */
+ static GTY((deletable (""))) rtx *old_reg_base_value;
+ static unsigned int old_reg_base_value_size;
+ 
  /* Static hunks of RTL used by the aliasing code; these are initialized
     once per function to avoid unnecessary RTL allocations.  */
  static GTY (()) rtx static_reg_base_value[FIRST_PSEUDO_REGISTER];
*************** init_alias_analysis (void)
*** 2730,2737 ****
    /* Overallocate reg_base_value to allow some growth during loop
       optimization.  Loop unrolling can create a large number of
       registers.  */
!   reg_base_value_size = maxreg * 2;
!   reg_base_value = ggc_alloc_cleared (reg_base_value_size * sizeof (rtx));
  
    new_reg_base_value = xmalloc (reg_base_value_size * sizeof (rtx));
    reg_seen = xmalloc (reg_base_value_size);
--- 2736,2755 ----
    /* Overallocate reg_base_value to allow some growth during loop
       optimization.  Loop unrolling can create a large number of
       registers.  */
!   if (maxreg <= old_reg_base_value_size
!       && old_reg_base_value)
!     {
!       reg_base_value = old_reg_base_value;
!       reg_base_value_size = old_reg_base_value_size;
!       if (reg_base_value_size > maxreg * 2)
! 	reg_base_value_size = maxreg * 2;
!       memset (reg_base_value, 0, reg_base_value_size * sizeof (rtx));
!     }
!   else
!     {
!       reg_base_value_size = maxreg * 2;
!       reg_base_value = ggc_alloc_cleared (reg_base_value_size * sizeof (rtx));
!     }
  
    new_reg_base_value = xmalloc (reg_base_value_size * sizeof (rtx));
    reg_seen = xmalloc (reg_base_value_size);
*************** init_alias_analysis (void)
*** 2928,2933 ****
--- 2946,2953 ----
  void
  end_alias_analysis (void)
  {
+   old_reg_base_value = reg_base_value;
+   old_reg_base_value_size = reg_base_value_size;
    free (reg_known_value + FIRST_PSEUDO_REGISTER);
    reg_known_value = 0;
    reg_known_value_size = 0;


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