From patchwork Fri Oct 8 11:13:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 67171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5BB4DB70A7 for ; Fri, 8 Oct 2010 22:13:43 +1100 (EST) Received: (qmail 27734 invoked by alias); 8 Oct 2010 11:13:41 -0000 Received: (qmail 27724 invoked by uid 22791); 8 Oct 2010 11:13:40 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Oct 2010 11:13:34 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id C706B94393; Fri, 8 Oct 2010 13:13:31 +0200 (CEST) Date: Fri, 8 Oct 2010 13:13:31 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Cc: Diego Novillo Subject: [PATCH][LTO] Stream BLOCKs lazily Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 * 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. 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);