From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25413 invoked by alias); 14 Oct 2009 15:55:37 -0000 Received: (qmail 25376 invoked by uid 22791); 14 Oct 2009 15:55:35 -0000 X-SWARE-Spam-Status: No, hits=-3.7 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Oct 2009 15:55:30 +0000 Received: from relay1.suse.de (relay-ext.suse.de [195.135.221.8]) by mx2.suse.de (Postfix) with ESMTP id DE9AA88B6C; Wed, 14 Oct 2009 17:55:27 +0200 (CEST) Date: Wed, 14 Oct 2009 16:18:00 -0000 From: Richard Guenther To: gcc-patches@gcc.gnu.org Cc: Diego Novillo Subject: [PATCH][LTO] Fixup FIELD_DECLs in COMPONENT_REFs Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2009-10/txt/msg00917.txt.bz2 The following replaces FIELD_DECLs with one from the canonical type in COMPONENT_REFs. FIELD_DECLs are the most prominent thing that we can't get rid of after type-merging because they are still referenced from the IL (curiously it's also one example for why we can't collect garbage after type-merging before streaming in all IL we ever want to stream in). This allows me to finish lto1 for 483.xalancbmk on a machine with 3GB ram where it previously failed running out of memory. Wasting memory with yet-another hashtable for doing the replacement would increase peak memory usage even further so I decided to do stupid list walks. IL streaming after this patch is only taking about 5% of the time we spend in fixing up decls and types before. Bootstrapped and tested on x86_64-unknown-linux-gnu, a full SPEC 2006 is running. Ok if that passes? Thanks, Richard. 2009-10-14 Richard Guenther * tree.c (free_lang_data_in_decl): Free DECL_FCONTEXT. * lto-streamer-in.c (input_gimple_stmt): Fixup FIELD_DECL operands in COMPONENT_REFs. Index: gcc/tree.c =================================================================== *** gcc/tree.c (revision 152768) --- gcc/tree.c (working copy) *************** free_lang_data_in_decl (tree decl) *** 4402,4407 **** --- 4402,4411 ---- && DECL_FIELD_OFFSET (decl) && TREE_CODE (DECL_FIELD_OFFSET (decl)) != INTEGER_CST) DECL_FIELD_OFFSET (decl) = NULL_TREE; + + /* DECL_FCONTEXT is only used for debug info generation. */ + if (TREE_CODE (decl) == FIELD_DECL) + DECL_FCONTEXT (decl) = NULL_TREE; } else if (TREE_CODE (decl) == FUNCTION_DECL) { Index: gcc/lto-streamer-in.c =================================================================== *** gcc/lto-streamer-in.c (revision 152768) --- gcc/lto-streamer-in.c (working copy) *************** input_gimple_stmt (struct lto_input_bloc *** 948,953 **** --- 948,979 ---- { tree op = lto_input_tree (ib, data_in); gimple_set_op (stmt, i, op); + + /* Fixup FIELD_DECLs. */ + while (op && handled_component_p (op)) + { + if (TREE_CODE (op) == COMPONENT_REF) + { + tree field, type, tem; + field = TREE_OPERAND (op, 1); + type = DECL_CONTEXT (field); + for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) + { + if (tem == field + || ((DECL_FIELD_OFFSET (tem) + == DECL_FIELD_OFFSET (field)) + && (DECL_FIELD_BIT_OFFSET (tem) + == DECL_FIELD_BIT_OFFSET (field)) + && (DECL_OFFSET_ALIGN (tem) + == DECL_OFFSET_ALIGN (field)))) + break; + } + gcc_assert (tem != NULL_TREE); + TREE_OPERAND (op, 1) = tem; + } + + op = TREE_OPERAND (op, 0); + } } break;