This is the mail archive of the gcc@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]

[PATCH] Remove all ggc'd bitmaps from PRE (Was Re: Memory overheadof tree-SSA optimization passes)


> For PRE we consume most of memory in bitmaps, I am just testing patch
> obstackeizing them that should actually help here reducing GGC garbage
> to 40MB but still I don't follow why we need such an extreme amount of
> bitmaps.

Here's a patch that removes all ggc'd bitmaps from PRE.

It's bootstrapping now (on a day old tree).
If all goes well, i'll rebootstrap and testwhen the tree isn't broken,
add a changelog, and commit it.

However, in any case, it should be usable for your measurement purposes.

Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-pre.c,v
retrieving revision 2.30
diff -u -p -r2.30 tree-ssa-pre.c
--- tree-ssa-pre.c	20 Aug 2004 16:48:00 -0000	2.30
+++ tree-ssa-pre.c	4 Sep 2004 16:14:37 -0000
@@ -468,7 +468,7 @@ value_insert_into_set_bitmap (value_set_
 
   if (set->values == NULL)
     {
-      set->values = BITMAP_GGC_ALLOC ();
+      set->values = BITMAP_XMALLOC ();
       bitmap_clear (set->values);
     }
 
@@ -482,13 +482,23 @@ static bitmap_set_t 
 bitmap_set_new (void)
 {
   bitmap_set_t ret = pool_alloc (bitmap_set_pool);
-  ret->expressions = BITMAP_GGC_ALLOC ();
-  ret->values = BITMAP_GGC_ALLOC ();
+  ret->expressions = BITMAP_XMALLOC ();
+  ret->values = BITMAP_XMALLOC ();
   bitmap_clear (ret->expressions);
   bitmap_clear (ret->values);
   return ret;
 }
 
+/* Free a bitmap set SET.  */
+
+static void
+bitmap_set_free (bitmap_set_t set)
+{
+  BITMAP_XFREE (set->expressions);
+  BITMAP_XFREE (set->values);
+  pool_free (bitmap_set_pool, set);
+}
+
 /* Create a new set.  */
 
 static value_set_t
@@ -503,6 +513,18 @@ set_new  (bool indexed)
   return ret;
 }
 
+/* Free a value set SET.  */
+static void
+value_set_free (value_set_t set)
+{
+  /* Note that we don't free the elements, they don't make up enough garbage
+  that it is worth the O(n) linked list walk.  The pool destruction at the end
+  of the PRE pass will free them for us.  */
+  if (set->indexed)
+    BITMAP_XFREE (set->values);
+  pool_free (value_set_pool, set);
+}
+
 /* Insert an expression EXPR into a bitmapped set.  */
 
 static void
@@ -1133,7 +1155,7 @@ compute_antic_aux (basic_block block)
   value_set_t S, old, ANTIC_OUT;
   value_set_node_t node;
   
-  ANTIC_OUT = S = NULL;
+  ANTIC_OUT = S = old = NULL;
   /* If any edges from predecessors are abnormal, antic_in is empty, so
      punt.  Remember that the block has an incoming abnormal edge by
      setting the BB_VISITED flag.  */
@@ -1152,7 +1174,6 @@ compute_antic_aux (basic_block block)
       goto visit_sons;
     }
   
-
   old = set_new (false);
   set_copy (old, ANTIC_IN (block));
   ANTIC_OUT = set_new (true);
@@ -1207,6 +1228,8 @@ compute_antic_aux (basic_block block)
   /* Generate ANTIC_OUT - TMP_GEN */
   S = bitmap_set_subtract_from_value_set (ANTIC_OUT, TMP_GEN (block), false);
 
+  value_set_free (ANTIC_IN (block));
+
   /* Start ANTIC_IN with EXP_GEN - TMP_GEN */
   ANTIC_IN (block) = bitmap_set_subtract_from_value_set (EXP_GEN (block), 
 							 TMP_GEN (block),
@@ -1237,6 +1260,9 @@ compute_antic_aux (basic_block block)
 
     }
 
+  value_set_free (S);
+  value_set_free (old);
+
   for (son = first_dom_son (CDI_POST_DOMINATORS, block);
        son;
        son = next_dom_son (CDI_POST_DOMINATORS, son))
@@ -1624,6 +1650,10 @@ insert (void)
     }
   if (num_iterations > 2 && dump_file && (dump_flags & TDF_STATS))
     fprintf (dump_file, "insert required %d iterations\n", num_iterations);
+
+  FOR_ALL_BB (bb)
+    bitmap_set_free (NEW_SETS (bb));
+  
 }
 
 
@@ -1979,22 +2009,28 @@ static void
 fini_pre (void)
 {
   basic_block bb;
-
-  free_alloc_pool (value_set_pool);
-  free_alloc_pool (bitmap_set_pool);
-  free_alloc_pool (value_set_node_pool);
-  free_alloc_pool (binary_node_pool);
-  free_alloc_pool (reference_node_pool);
-  free_alloc_pool (unary_node_pool);
+  
   htab_delete (phi_translate_table);
   remove_fake_exit_edges ();
 
   FOR_ALL_BB (bb)
     {
+      value_set_free (EXP_GEN (bb));
+      bitmap_set_free (PHI_GEN (bb));
+      bitmap_set_free (TMP_GEN (bb));
+      bitmap_set_free (AVAIL_OUT (bb));
+      value_set_free (ANTIC_IN (bb));
       free (bb->aux);
       bb->aux = NULL;
     }
 
+  free_alloc_pool (value_set_pool);
+  free_alloc_pool (bitmap_set_pool);
+  free_alloc_pool (value_set_node_pool);
+  free_alloc_pool (binary_node_pool);
+  free_alloc_pool (reference_node_pool);
+  free_alloc_pool (unary_node_pool);
+
   free_dominance_info (CDI_POST_DOMINATORS);
   vn_delete ();
 

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