gcc-patches@gcc.gnu.org
[Top] [All Lists]

Some more memory usage reductions in bitmaps

Subject: Some more memory usage reductions in bitmaps
From: Jan Hubicka
Date: Tue, 1 Aug 2006 00:50:49 +0200
Hi,
the bitmap statistic code shows few spots where rather large amount of memory
are allocated by not released early.  This patch hits two most common spots 
(expcept for new_insn_chain in reload.c I don't understand very well yet).
In the tree-out-of-ssa case the bitmap is most of time allocated even tought
the function returns early and don't need it.
In the tree-ssa-pre the bitmaps are kept on pass local obstack and even the
very temporary ones not freed.  While this seems rather safe, the bitmaps
grows almost to a gig on my favorite testcase before compilation aborts
on out-of-memory, so the change on two common spots makes the pass live
longer (before exhausting memory anyway)

Bootstrapped/regtested i686-linux, OK?

:ADDPATCH middle-end:
Honza

        * tree-outof-ssa.c (check_replaceable): Do not allocate def_vars
        bitmap when not needed.
        * tree-ssa-pre.c (bitmap_set_and, bitmap_set_and_compl): Free temporary
        bitmaps.
Index: tree-outof-ssa.c
===================================================================
-u -L tree-outof-ssa.c  (revision 115809) -L tree-outof-ssa.c   (working copy) 
.svn/text-base/tree-outof-ssa.c.svn-base tree-outof-ssa.c
--- tree-outof-ssa.c    (revision 115809)
+++ tree-outof-ssa.c    (working copy)
@@ -1556,7 +1556,7 @@ check_replaceable (temp_expr_table_p tab
   var_map map = tab->map;
   ssa_op_iter iter;
   tree call_expr;
-  bitmap def_vars = BITMAP_ALLOC (NULL), use_vars;
+  bitmap def_vars, use_vars;
 
   if (TREE_CODE (stmt) != MODIFY_EXPR)
     return false;
@@ -1588,6 +1588,7 @@ check_replaceable (temp_expr_table_p tab
 
   version = SSA_NAME_VERSION (def);
   basevar = SSA_NAME_VAR (def);
+  def_vars = BITMAP_ALLOC (NULL);
   bitmap_set_bit (def_vars, DECL_UID (basevar));
 
   /* Add this expression to the dependency list for each use partition.  */
Index: tree-ssa-pre.c
===================================================================
-u -L tree-ssa-pre.c    (revision 115809) -L tree-ssa-pre.c     (working copy) 
.svn/text-base/tree-ssa-pre.c.svn-base tree-ssa-pre.c
--- tree-ssa-pre.c      (revision 115809)
+++ tree-ssa-pre.c      (working copy)
@@ -624,7 +624,7 @@ bitmap_set_and (bitmap_set_t dest, bitma
       if (!bitmap_bit_p (dest->values, VALUE_HANDLE_ID (val)))
        bitmap_clear_bit (dest->expressions, i);
     }
-
+  BITMAP_FREE (temp);
 }
 
 /* Perform bitmapped value set operation DEST = DEST & ~ORIG.  */
@@ -645,6 +645,7 @@ bitmap_set_and_compl (bitmap_set_t dest,
       if (!bitmap_bit_p (dest->values, VALUE_HANDLE_ID (val)))
        bitmap_clear_bit (dest->expressions, i);
     }
+  BITMAP_FREE (temp);
 }
 
 /* Return true if the bitmap set SET is empty.  */

<Prev in Thread] Current Thread [Next in Thread>