From patchwork Tue Sep 13 19:03:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 114545 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 7FFEBB71BC for ; Wed, 14 Sep 2011 05:03:55 +1000 (EST) Received: (qmail 16673 invoked by alias); 13 Sep 2011 19:03:52 -0000 Received: (qmail 16664 invoked by uid 22791); 13 Sep 2011 19:03:50 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 13 Sep 2011 19:03:36 +0000 Received: from wpaz37.hot.corp.google.com (wpaz37.hot.corp.google.com [172.24.198.101]) by smtp-out.google.com with ESMTP id p8DJ3XuO022101; Tue, 13 Sep 2011 12:03:34 -0700 Received: from topo.tor.corp.google.com (topo.tor.corp.google.com [172.29.41.2]) by wpaz37.hot.corp.google.com with ESMTP id p8DJ3WFF025863; Tue, 13 Sep 2011 12:03:32 -0700 Received: by topo.tor.corp.google.com (Postfix, from userid 54752) id C6B5D1DA1A3; Tue, 13 Sep 2011 15:03:31 -0400 (EDT) To: reply@codereview.appspotmail.com, crowl@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Add pph_writer_enabled_p (issue5003044) Message-Id: <20110913190331.C6B5D1DA1A3@topo.tor.corp.google.com> Date: Tue, 13 Sep 2011 15:03:31 -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 A small tweak to clarify what we mean when the code reads 'if (pph_out_file)'. For the next patch I'm writing, I'm using this, so I'm flushing it first. Tested on x86_64. Applied. Diego. c-family/ChangeLog.pph * c-opts.c (pph_reader_enabled_p): Rename from query_have_pph_map. Update all users. cp/ChangeLog.pph * Make-lang.in (cp/parser.o): Add dependency on CXX_PPH_STREAMER_H. * parser.c: Include pph-streamer.h * decl.c (cp_rest_of_decl_compilation): Call pph_writer_enabled_p. * pph-streamer-in.c (pph_read_file_1): Likewise. * semantics.c (expand_or_defer_fn_1): Likewise. * pph-streamer.h (pph_writer_enabled_p): New. (pph_enabled_p): Move from pph.h. * pph.c (pph_init): Call pph_writer_enabled_p. * pph.h: Move to pph-streamer.h. --- This patch is available for review at http://codereview.appspot.com/5003044 diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 6f4dc1c..56dada4 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -584,10 +584,10 @@ extern const char *pch_file; extern const char *pph_out_file; -/* Query if we have any map from INCLUDE to PPH file. */ +/* Return true if we have any map from INCLUDE to PPH file. */ extern bool -query_have_pph_map (void); +pph_reader_enabled_p (void); /* Query for a mapping from an INCLUDE to a PPH file. Return the filename, without ownership. diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 3ee5860..6b63bda 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -129,13 +129,13 @@ static void c_finish_options (void); #endif /* Mappings from include directive to PPH file. */ +static strstrmap_t *include_pph_mapping; -strstrmap_t *include_pph_mapping; -/* Query if we have any map from INCLUDE to PPH file. */ +/* Return true if we have any map from INCLUDE to PPH file. */ bool -query_have_pph_map (void) +pph_reader_enabled_p (void) { return include_pph_mapping != NULL; } diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index a83d5a2..fe2b87e 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -342,7 +342,7 @@ cp/mangle.o: cp/mangle.c $(CXX_TREE_H) $(TM_H) $(REAL_H) \ cp/parser.o: cp/parser.c $(CXX_TREE_H) $(TM_H) $(DIAGNOSTIC_CORE_H) \ gt-cp-parser.h output.h $(TARGET_H) $(PLUGIN_H) intl.h \ c-family/c-objc.h tree-pretty-print.h $(CXX_PARSER_H) $(TIMEVAR.H) \ - $(CXX_PPH_H) + $(CXX_PPH_H) $(CXX_PPH_STREAMER_H) cp/cp-gimplify.o: cp/cp-gimplify.c $(CXX_TREE_H) $(C_COMMON_H) \ $(TM_H) coretypes.h pointer-set.h tree-iterator.h $(SPLAY_TREE_H) cp/name-lookup.o: cp/name-lookup.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e10eb88..cd3d0aa 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5906,7 +5906,7 @@ cp_rest_of_decl_compilation (tree decl, int top_level, int at_end) rest_of_decl_compilation (decl, top_level, at_end); /* If we are generating a PPH image, add DECL to its symbol table. */ - if (pph_out_file) + if (pph_writer_enabled_p ()) pph_add_decl_to_symtab (decl, PPH_SYMTAB_DECLARE, top_level, at_end); } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7253df6..3d476d6 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see #include "timevar.h" #include "cpplib.h" #include "pph.h" +#include "pph-streamer.h" #include "tree.h" #include "cp-tree.h" #include "intl.h" diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c index ea44460..f8238bf 100644 --- a/gcc/cp/pph-streamer-in.c +++ b/gcc/cp/pph-streamer-in.c @@ -1669,7 +1669,7 @@ pph_read_file_1 (pph_stream *stream) /* If we are generating an image, the PPH contents we just read from STREAM will need to be read again the next time we want to read the image we are now generating. */ - if (pph_out_file && !pph_reading_includes) + if (pph_writer_enabled_p () && !pph_reading_includes) pph_add_include (stream); } diff --git a/gcc/cp/pph-streamer.h b/gcc/cp/pph-streamer.h index 7f98764..ce2f379 100644 --- a/gcc/cp/pph-streamer.h +++ b/gcc/cp/pph-streamer.h @@ -281,6 +281,21 @@ extern void pph_in_spec_entry_tables (pph_stream *stream); /* Inline functions. */ +/* Return true if we are generating a PPH image. */ +static inline bool +pph_writer_enabled_p (void) +{ + return pph_out_file != NULL; +} + +/* Return true if PPH has been enabled. */ +static inline bool +pph_enabled_p (void) +{ + return pph_writer_enabled_p () || pph_reader_enabled_p (); +} + + /* Output array A of cardinality C of ASTs to STREAM. */ /* FIXME pph: hold for alternate routine. */ #if 0 diff --git a/gcc/cp/pph.c b/gcc/cp/pph.c index cbd9c24..24744bb 100644 --- a/gcc/cp/pph.c +++ b/gcc/cp/pph.c @@ -186,7 +186,7 @@ pph_init (void) gcc_assert (table == NULL); /* If we are generating a PPH file, initialize the writer. */ - if (pph_out_file != NULL) + if (pph_writer_enabled_p ()) pph_writer_init (); pph_init_preloaded_cache (); diff --git a/gcc/cp/pph.h b/gcc/cp/pph.h index 2197744..bc90f80 100644 --- a/gcc/cp/pph.h +++ b/gcc/cp/pph.h @@ -56,13 +56,6 @@ typedef struct cp_token_hunk *cp_token_hunk_ptr; DEF_VEC_P (cp_token_hunk_ptr); DEF_VEC_ALLOC_P (cp_token_hunk_ptr,gc); -/* Return true if PPH has been enabled. */ -static inline bool -pph_enabled_p (void) -{ - return pph_out_file != NULL || query_have_pph_map (); -} - /* Global state. FIXME pph, get rid of these. */ /* Log file where PPH analysis is written to. Controlled by diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 868adb6..cd6ebac 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3571,7 +3571,7 @@ bool expand_or_defer_fn_1 (tree fn) { /* If we are generating a PPH image, add FN to its symbol table. */ - if (pph_out_file) + if (pph_writer_enabled_p ()) pph_add_decl_to_symtab (fn, PPH_SYMTAB_EXPAND, false, at_eof); /* When the parser calls us after finishing the body of a template