Patchwork [LTO] Stream BLOCKs lazily

login
register
mail settings
Submitter Richard Guenther
Date Oct. 8, 2010, 11:13 a.m.
Message ID <alpine.LNX.2.00.1010081309570.8982@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/67171/
State New
Headers show

Comments

Richard Guenther - Oct. 8, 2010, 11:13 a.m.
This makes us stream BLOCKs lazily (thus, only when referenced).
Which actually means not following BLOCK_CHAIN but re-constructing
it on-the-fly when reading a BLOCK.  This reduces WPA memory
building 447.dealII by 2% (not too much, I'm now trying to not stream
BLOCK_VARs in a similar way).

Anyway, I think it makes sense.

Bootstrapped and tested on x86_64-unknown-linux-gnu, I built SPEC 2k6
with -fwhopr as well (which unpatched shows a load of issues with
checking enabled already) with no appearant regressions due to
this patch.

Ok for trunk?

Thanks,
Richard.

2010-10-08  Richard Guenther  <rguenther@suse.de>

	* lto-streamer-out.c (lto_output_ts_block_tree_pointers):
	Do not output BLOCK_SUBBLOCKS.
	* lto-streamer-in.c (lto_input_ts_block_tree_pointers):
	Reserve exact space needed for BLOCK_NONLOCALIZED_VARS.
	Re-construct BLOCK_SUBBLOCKS of parent block.
	(lto_input_ts_binfo_tree_pointers): Reserve exact space needed
	for BINFO_BASE_ACCESSES.
Diego Novillo - Oct. 8, 2010, 3:13 p.m.
On Fri, Oct 8, 2010 at 04:13, Richard Guenther <rguenther@suse.de> wrote:

> 2010-10-08  Richard Guenther  <rguenther@suse.de>
>
>        * lto-streamer-out.c (lto_output_ts_block_tree_pointers):
>        Do not output BLOCK_SUBBLOCKS.
>        * lto-streamer-in.c (lto_input_ts_block_tree_pointers):
>        Reserve exact space needed for BLOCK_NONLOCALIZED_VARS.
>        Re-construct BLOCK_SUBBLOCKS of parent block.
>        (lto_input_ts_binfo_tree_pointers): Reserve exact space needed
>        for BINFO_BASE_ACCESSES.

OK.


Diego.

Patch

Index: gcc/lto-streamer-out.c
===================================================================
--- gcc/lto-streamer-out.c	(revision 165150)
+++ gcc/lto-streamer-out.c	(working copy)
@@ -1065,7 +1065,8 @@  lto_output_ts_block_tree_pointers (struc
   lto_output_tree_or_ref (ob, BLOCK_ABSTRACT_ORIGIN (expr), ref_p);
   lto_output_tree_or_ref (ob, BLOCK_FRAGMENT_ORIGIN (expr), ref_p);
   lto_output_tree_or_ref (ob, BLOCK_FRAGMENT_CHAIN (expr), ref_p);
-  lto_output_chain (ob, BLOCK_SUBBLOCKS (expr), ref_p);
+  /* Do not output BLOCK_SUBBLOCKS.  Instead on streaming-in this
+     list is re-constructed from BLOCK_SUPERCONTEXT.  */
 }
 
 
Index: gcc/lto-streamer-in.c
===================================================================
--- gcc/lto-streamer-in.c	(revision 165150)
+++ gcc/lto-streamer-in.c	(working copy)
@@ -2139,17 +2169,29 @@  lto_input_ts_block_tree_pointers (struct
   BLOCK_VARS (expr) = lto_input_chain (ib, data_in);
 
   len = lto_input_uleb128 (ib);
-  for (i = 0; i < len; i++)
+  if (len > 0)
     {
-      tree t = lto_input_tree (ib, data_in);
-      VEC_safe_push (tree, gc, BLOCK_NONLOCALIZED_VARS (expr), t);
+      VEC_reserve_exact (tree, gc, BLOCK_NONLOCALIZED_VARS (expr), len);
+      for (i = 0; i < len; i++)
+	{
+	  tree t = lto_input_tree (ib, data_in);
+	  VEC_quick_push (tree, BLOCK_NONLOCALIZED_VARS (expr), t);
+	}
     }
 
   BLOCK_SUPERCONTEXT (expr) = lto_input_tree (ib, data_in);
   BLOCK_ABSTRACT_ORIGIN (expr) = lto_input_tree (ib, data_in);
   BLOCK_FRAGMENT_ORIGIN (expr) = lto_input_tree (ib, data_in);
   BLOCK_FRAGMENT_CHAIN (expr) = lto_input_tree (ib, data_in);
-  BLOCK_SUBBLOCKS (expr) = lto_input_chain (ib, data_in);
+  /* We re-compute BLOCK_SUBBLOCKS of our parent here instead
+     of streaming it.  For non-BLOCK BLOCK_SUPERCONTEXTs we still
+     stream the child relationship explicitly.  */
+  if (BLOCK_SUPERCONTEXT (expr)
+      && TREE_CODE (BLOCK_SUPERCONTEXT (expr)) == BLOCK)
+    {
+      BLOCK_CHAIN (expr) = BLOCK_SUBBLOCKS (BLOCK_SUPERCONTEXT (expr));
+      BLOCK_SUBBLOCKS (BLOCK_SUPERCONTEXT (expr)) = expr;
+    }
 }
 
 
@@ -2183,10 +2225,14 @@  lto_input_ts_binfo_tree_pointers (struct
   BINFO_VPTR_FIELD (expr) = lto_input_tree (ib, data_in);
 
   len = lto_input_uleb128 (ib);
-  for (i = 0; i < len; i++)
+  if (len > 0)
     {
-      tree a = lto_input_tree (ib, data_in);
-      VEC_safe_push (tree, gc, BINFO_BASE_ACCESSES (expr), a);
+      VEC_reserve_exact (tree, gc, BINFO_BASE_ACCESSES (expr), len);
+      for (i = 0; i < len; i++)
+	{
+	  tree a = lto_input_tree (ib, data_in);
+	  VEC_quick_push (tree, BINFO_BASE_ACCESSES (expr), a);
+	}
     }
 
   BINFO_INHERITANCE_CHAIN (expr) = lto_input_tree (ib, data_in);