From patchwork Thu Aug 4 17:12:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 108543 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 3AE34B6F7A for ; Fri, 5 Aug 2011 03:12:49 +1000 (EST) Received: (qmail 27680 invoked by alias); 4 Aug 2011 17:12:45 -0000 Received: (qmail 27672 invoked by uid 22791); 4 Aug 2011 17:12:43 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_CP X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Aug 2011 17:12:29 +0000 Received: from kpbe15.cbf.corp.google.com (kpbe15.cbf.corp.google.com [172.25.105.79]) by smtp-out.google.com with ESMTP id p74HCSpX031274; Thu, 4 Aug 2011 10:12:28 -0700 Received: from topo.tor.corp.google.com (topo.tor.corp.google.com [172.29.41.2]) by kpbe15.cbf.corp.google.com with ESMTP id p74HCQXl005143; Thu, 4 Aug 2011 10:12:26 -0700 Received: by topo.tor.corp.google.com (Postfix, from userid 54752) id F29BA1DA1B5; Thu, 4 Aug 2011 13:12:25 -0400 (EDT) To: reply@codereview.appspotmail.com, crowl@google.com, gchare@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Allocate string tables separately. (issue4843044) Message-Id: <20110804171225.F29BA1DA1B5@topo.tor.corp.google.com> Date: Thu, 4 Aug 2011 13:12:25 -0400 (EDT) From: dnovillo@google.com (Diego Novillo) X-System-Of-Record: true X-IsSubscribed: yes 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 patch separates the string tables from input streams to allow the string tables to remain allocated throughout the compilation process. Gab, I think this addresses the problem you were seeing with your line number changes. Let me know if it doesn't. Tested on x86_64. Committed to branch. * pph-streamer-in.c (string_tables): Declare. (pph_init_read): Create a new entry in string_tables and copy the string table from STREAM into it. --- This patch is available for review at http://codereview.appspot.com/4843044 diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c index 15c5032..e57e1e7 100644 --- a/gcc/cp/pph-streamer-in.c +++ b/gcc/cp/pph-streamer-in.c @@ -33,6 +33,19 @@ along with GCC; see the file COPYING3. If not see #include "cppbuiltin.h" #include "toplev.h" +typedef char *char_p; +DEF_VEC_P(char_p); +DEF_VEC_ALLOC_P(char_p,heap); + +/* String tables for all input streams. These are allocated separately + from streams because they cannot be deallocated after the streams + have been read (string streaming works by pointing into these + tables). + + Each stream will create a new entry in this table of tables. The + memory will remain allocated until the end of compilation. */ +static VEC(char_p,heap) *string_tables = NULL; + /* Wrapper for memory allocation calls that should have their results registered in the PPH streamer cache. DATA is the pointer returned by the memory allocation call in ALLOC_EXPR. IX is the cache slot @@ -106,6 +119,7 @@ pph_init_read (pph_stream *stream) int retcode; pph_file_header *header; const char *strtab, *body; + char *new_strtab; lto_reader_init (); @@ -134,16 +148,25 @@ pph_init_read (pph_stream *stream) body_size = stream->encoder.r.file_size - strtab_size - sizeof (pph_file_header); + /* Create a new string table for STREAM. This table is not part of + STREAM because it needs to remain around until the end of + compilation (all the string streaming routines work by pointing + into the string table, so we cannot deallocate it after reading + STREAM). */ + new_strtab = XNEWVEC (char, strtab_size); + memcpy (new_strtab, strtab, strtab_size); + VEC_safe_push (char_p, heap, string_tables, new_strtab); + /* Create an input block structure pointing right after the string table. */ stream->encoder.r.ib = XCNEW (struct lto_input_block); LTO_INIT_INPUT_BLOCK_PTR (stream->encoder.r.ib, body, 0, body_size); stream->encoder.r.data_in - = lto_data_in_create (stream->encoder.r.pph_sections[0], strtab, - strtab_size, NULL); + = lto_data_in_create (stream->encoder.r.pph_sections[0], + new_strtab, strtab_size, NULL); - /* Associate STREAM with STREAM->ENCODER.R.DATA_IN so we can recover it from - the streamer hooks. */ + /* Associate STREAM with STREAM->ENCODER.R.DATA_IN so we can recover + it from the streamer hooks. */ stream->encoder.r.data_in->sdata = (void *) stream; }