From patchwork Tue Jan 17 16:34:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 136498 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 7BD091007D1 for ; Wed, 18 Jan 2012 03:35:18 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1327422919; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:To:Subject:Message-Id:Date: From:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=msieXd4 7Jp5xZPiF1Ce6549gmIY=; b=RvNpMiCvz8pHCIiqcmEVzzPQ/8h+UBPgbtTzZlG Xj4SgMywwmFfG9X6pMiqdPDLMSsu9j02hd4oRDxYAL2qPtN0FZw5JaRlbP8dF5Pi lRU20yu5PzrLYGB66JHckBTzkQDzQ1eJkn0WL/UEGwBa2dharJJcYx31WFSv2OgA SQ/E= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=xdiwUl/pmmxkUQcOVFHjy6saH8fiaNzywy+WcrvPQyvmAqq0lGS6xZfoENd1Xy qdQrhAKSHlJMap3ai7VKTuMr0h0wuAAXSFUaIwsQZwnOQih2tWtWgU/EhvyavCJe /D0C54C+lCpjitQtmS4SaBkZzR9H1OGjbRNgWkfVTZ0nc=; Received: (qmail 15375 invoked by alias); 17 Jan 2012 16:35:14 -0000 Received: (qmail 14881 invoked by uid 22791); 17 Jan 2012 16:35:12 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-yx0-f201.google.com (HELO mail-yx0-f201.google.com) (209.85.213.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Jan 2012 16:34:59 +0000 Received: by yenl2 with SMTP id l2so182770yen.2 for ; Tue, 17 Jan 2012 08:34:58 -0800 (PST) Received: by 10.236.77.37 with SMTP id c25mr2821617yhe.5.1326818098599; Tue, 17 Jan 2012 08:34:58 -0800 (PST) Received: by 10.236.77.37 with SMTP id c25mr2821588yhe.5.1326818098544; Tue, 17 Jan 2012 08:34:58 -0800 (PST) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id j11si15836546ane.2.2012.01.17.08.34.58 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 17 Jan 2012 08:34:58 -0800 (PST) Received: from topo.tor.corp.google.com (topo.tor.corp.google.com [172.29.41.2]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 724F91E004D; Tue, 17 Jan 2012 08:34:58 -0800 (PST) Received: by topo.tor.corp.google.com (Postfix, from userid 54752) id BA7751DA1BE; Tue, 17 Jan 2012 11:34:57 -0500 (EST) To: reply@codereview.appspotmail.com, crowl@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Fix in-memory marking (take 2) (issue5540069) Message-Id: <20120117163457.BA7751DA1BE@topo.tor.corp.google.com> Date: Tue, 17 Jan 2012 11:34:57 -0500 (EST) From: dnovillo@google.com (Diego Novillo) 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 My previous patch moved the in_memory marker to the wrong place. We need to prevent a file from being re-read by an #include from one of its included children images. This is common in system headers. We mark the file as resident in-memory right before we start reading its includes. Before, we were marking it when the file was initially registered. This was causing us to completely ignore needed PPH images. * pph-core.c (pph_stream_register): Move in-memory marking... * pph-in.c (pph_read_file_1): ... here. --- This patch is available for review at http://codereview.appspot.com/5540069 diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c index 9f7f063..6d34bd0 100644 --- a/gcc/cp/pph-core.c +++ b/gcc/cp/pph-core.c @@ -953,10 +953,6 @@ pph_stream_register (pph_stream *stream) /* Add a mapping between STREAM's PPH file name and STREAM. */ pph_stream_registry_add_name (stream, stream->name); - - /* Mark this file as being in memory. This prevents opening the - same file more than twice. */ - stream->in_memory_p = true; } diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c index e9a5563..827c8fd 100644 --- a/gcc/cp/pph-in.c +++ b/gcc/cp/pph-in.c @@ -2839,11 +2839,17 @@ pph_read_file_1 (pph_stream *stream) VEC(tree,gc) *file_unemitted_tinfo_decls; source_location cpp_token_replay_loc; - /* If we have opened STREAM before, we do not need to re-read the rest - of its body. */ + /* If we already have STREAM in memory (or are reading it), ignore + this request. */ if (stream->in_memory_p) return; + /* Mark this file as being in memory. This prevents multiple reads + from the same file. This scenario can happen in #include chains + where the top header file is also included by one of its children + (common in system headers). */ + stream->in_memory_p = true; + if (flag_pph_tracer >= 1) fprintf (pph_logfile, "PPH: Reading %s\n", stream->name);