Patchwork [pph] Changes to generic support code [3/3]

login
register
mail settings
Submitter Diego Novillo
Date Nov. 2, 2010, 11:10 p.m.
Message ID <20101102231055.GA19720@google.com>
Download mbox | patch
Permalink /patch/69931/
State New
Headers show

Comments

Diego Novillo - Nov. 2, 2010, 11:10 p.m.
These are changes to generic machinery, timers, language hooks,
flags and such.  


2010-11-02  Lawrence Crowl  <crowl@google.com>
	    Diego Novillo  <dnovillo@google.com>

	* tree-pretty-print.c (dump_generic_node): Protect
	against NULL TREE_TYPE.
	* c-family/c.opt (fpph, fpph-debug, fpph-decls,
	fpph-logfile, pph-stats): Add.
	(fpth, fpth-debug, fpth-stats, fpth-md5): Add.
	* c-family/c-opts.c (c_common_finish): Do not write a
	deps file when generating PTH images.
	* tree.c (make_node_stat): Call
	lang_hooks.pph_catch_tree, if defined.
	* input.h (LOCATION_COLUMN): Define.
	* timevar.def (TV_PTH_DEPENDENCY): Define.
	(TV_PTH_MANAGE): Define.
	(TV_PTH_MD5): Define.
	(TV_PTH_LOAD): Define.
	(TV_PTH_SAVE): Define.
	(TV_PTH_SKIP_TOKENS): Define.
	(TV_PTH_INIT): Define.
	(TV_PPH_CACHE_IN): Define.
	(TV_PPH_CACHE_OUT): Define.
	(TV_PPH_MANAGE): Define.
	* langhooks.h: Add fields pph_catch_tree and pph_uncatch_tree.
	* tree-inline.c (copy_tree_r): Tolerate STATEMENT_LISTs
	when DATA is not NULL.
	* langhooks-def.h (LANG_HOOKS_PPH_UNCATCH_TREE): Define.
	(LANG_HOOKS_PPH_CATCH_TREE): Define.
	(LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_PPH_UNCATCH_TREE
	and LANG_HOOKS_PPH_CATCH_TREE.

Patch

Index: gcc/tree-pretty-print.c
===================================================================
--- gcc/tree-pretty-print.c	(revision 166136)
+++ gcc/tree-pretty-print.c	(working copy)
@@ -1124,7 +1124,7 @@  dump_generic_node (pretty_printer *buffe
 	}
       if (DECL_NAME (node))
 	dump_decl_name (buffer, node, flags);
-      else if (TYPE_NAME (TREE_TYPE (node)) != node)
+      else if (TREE_TYPE (node) && TYPE_NAME (TREE_TYPE (node)) != node)
 	{
 	  if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
 	       || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt	(revision 166136)
+++ gcc/c-family/c.opt	(working copy)
@@ -897,6 +897,26 @@  fplan9-extensions
 C ObjC Var(flag_plan9_extensions)
 Enable Plan 9 language extensions
 
+fpph
+C++ Var(flag_pph)
+-fpph   Enable pre-parsed header (PPH) support
+
+fpph-debug=
+C++ Joined RejectNegative UInteger Var(flag_pph_debug)
+-fpph-debug=N   Enable debugging output at level N from PPH support
+
+fpph-decls=
+C++ Joined RejectNegative UInteger Var(flag_pph_decls)
+-fpph-decls=N   Enable declaration identifier output at level N from PPH support
+
+fpph-logfile=
+C++ Joined RejectNegative Var(flag_pph_logfile)
+-fpph-logfile=<file-name>	Emit PPH debug information to <file-name>
+
+fpph-stats
+C++ Var(flag_pph_stats)
+-fpph-stats	Enable statistics gathering for PPH
+
 fpreprocessed
 C ObjC C++ ObjC++
 Treat the input file as already preprocessed
@@ -905,6 +925,22 @@  fpretty-templates
 C++ ObjC++ Var(flag_pretty_templates) Init(1)
 -fno-pretty-templates Do not pretty-print template specializations as the template signature followed by the arguments
 
+fpth
+C++ Var(flag_pth)
+-fpth	Enable pre-tokenized header (PTH) support
+
+fpth-debug=
+C++ Joined RejectNegative UInteger Var(flag_pth_debug)
+-fpth-debug=N	Enable debugging output at level N from PTH support
+
+fpth-stats
+C++ Var(flag_pth_stats)
+-fpth-stats	Enable statistics gathering for PTH
+
+fpth-md5
+C++ Var(flag_pth_md5)
+-fpth-md5   Use MD5 digests instead of timestamps to determine if a header file has changed
+
 freplace-objc-classes
 ObjC ObjC++ Var(flag_replace_objc_classes)
 Used in Fix-and-Continue mode to indicate that object files may be swapped in at runtime
Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c	(revision 166136)
+++ gcc/c-family/c-opts.c	(working copy)
@@ -1183,6 +1183,12 @@  c_common_finish (void)
 {
   FILE *deps_stream = NULL;
 
+  /* FIXME.  Hack!  When using a PTH image, we did not allow the 
+     pre-processor to keep track of dependencies, so we cannot
+     write them out.  */
+  if (flag_pth)
+    return;
+
   /* Don't write the deps file if there are errors.  */
   if (cpp_opts->deps.style != DEPS_NONE && !seen_error ())
     {
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 166136)
+++ gcc/tree.c	(working copy)
@@ -888,6 +888,8 @@  make_node_stat (enum tree_code code MEM_
       if (TREE_CODE (t) == LABEL_DECL)
 	LABEL_DECL_UID (t) = -1;
 
+      if (lang_hooks.pph_catch_tree)
+	lang_hooks.pph_catch_tree (t);
       break;
 
     case tcc_type:
Index: gcc/input.h
===================================================================
--- gcc/input.h	(revision 166136)
+++ gcc/input.h	(working copy)
@@ -61,6 +61,7 @@  extern location_t input_location;
 
 #define LOCATION_FILE(LOC) ((expand_location (LOC)).file)
 #define LOCATION_LINE(LOC) ((expand_location (LOC)).line)
+#define LOCATION_COLUMN(LOC) ((expand_location (LOC)).column)
 
 #define input_line LOCATION_LINE (input_location)
 #define input_filename LOCATION_FILE (input_location)
Index: gcc/timevar.def
===================================================================
--- gcc/timevar.def	(revision 166136)
+++ gcc/timevar.def	(working copy)
@@ -48,6 +48,20 @@  DEFTIMEVAR (TV_PCH_PTR_SORT          , "
 DEFTIMEVAR (TV_PCH_RESTORE           , "PCH main state restore")
 DEFTIMEVAR (TV_PCH_CPP_RESTORE       , "PCH preprocessor state restore")
 
+/* Time spent handling PTH state.  */
+DEFTIMEVAR (TV_PTH_DEPENDENCY        , "PTH dependency checks")
+DEFTIMEVAR (TV_PTH_MANAGE            , "PTH bookkeeping")
+DEFTIMEVAR (TV_PTH_MD5               , "PTH MD5 signatures")
+DEFTIMEVAR (TV_PTH_LOAD              , "PTH stream load")
+DEFTIMEVAR (TV_PTH_SAVE              , "PTH stream save")
+DEFTIMEVAR (TV_PTH_SKIP_TOKENS       , "PTH skip cached tokens")
+DEFTIMEVAR (TV_PTH_INIT              , "PTH initialization")
+
+/* Time spent handling PPH state.  */
+DEFTIMEVAR (TV_PPH_CACHE_IN          , "PPH cache in")
+DEFTIMEVAR (TV_PPH_CACHE_OUT         , "PPH cache out")
+DEFTIMEVAR (TV_PPH_MANAGE            , "PPH bookkeeping")
+
 DEFTIMEVAR (TV_CGRAPH                , "callgraph construction")
 DEFTIMEVAR (TV_CGRAPHOPT             , "callgraph optimization")
 DEFTIMEVAR (TV_VARPOOL               , "varpool construction")
Index: gcc/langhooks.h
===================================================================
--- gcc/langhooks.h	(revision 166136)
+++ gcc/langhooks.h	(working copy)
@@ -466,6 +466,11 @@  struct lang_hooks
      gimplification.  */
   bool deep_unsharing;
 
+  /* Used by pre-parsed header (PPH) to intercept certain tree nodes
+     created by make_node_stat during parsing.  */
+  void (*pph_catch_tree) (tree t);
+  void (*pph_uncatch_tree) (tree t);
+
   /* Whenever you add entries here, make sure you adjust langhooks-def.h
      and langhooks.c accordingly.  */
 };
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c	(revision 166136)
+++ gcc/tree-inline.c	(working copy)
@@ -4257,7 +4257,7 @@  optimize_inline_calls (tree fn)
 /* Passed to walk_tree.  Copies the node pointed to, if appropriate.  */
 
 tree
-copy_tree_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
+copy_tree_r (tree *tp, int *walk_subtrees, void *data)
 {
   enum tree_code code = TREE_CODE (*tp);
   enum tree_code_class cl = TREE_CODE_CLASS (code);
@@ -4318,7 +4318,12 @@  copy_tree_r (tree *tp, int *walk_subtree
     *walk_subtrees = 0;
   else if (TREE_CODE_CLASS (code) == tcc_constant)
     *walk_subtrees = 0;
-  else
+  else if (data == NULL)
+    /* FIXME pph.  DATA is non-NULL only when called from
+       pph_copy_decls_into_cache.  We don't really need to handle
+       STATEMENT_LISTs properly, just do the copy to collect rough
+       timings.  This routine will need to be revamped when we are
+       caching for real.  */
     gcc_assert (code != STATEMENT_LIST);
   return NULL_TREE;
 }
Index: gcc/langhooks-def.h
===================================================================
--- gcc/langhooks-def.h	(revision 166136)
+++ gcc/langhooks-def.h	(working copy)
@@ -112,6 +112,8 @@  extern void lhd_omp_firstprivatize_type_
 #define LANG_HOOKS_BUILTIN_FUNCTION	lhd_builtin_function
 #define LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE	LANG_HOOKS_BUILTIN_FUNCTION
 #define LANG_HOOKS_EXPR_TO_DECL		lhd_expr_to_decl
+#define LANG_HOOKS_PPH_CATCH_TREE	NULL
+#define LANG_HOOKS_PPH_UNCATCH_TREE	NULL
 #define LANG_HOOKS_TO_TARGET_CHARSET	lhd_to_target_charset
 #define LANG_HOOKS_INIT_TS		lhd_do_nothing
 #define LANG_HOOKS_EH_PERSONALITY	lhd_gcc_personality
@@ -308,7 +310,9 @@  extern void lhd_end_section (void);
   LANG_HOOKS_EH_RUNTIME_TYPE, \
   LANG_HOOKS_EH_PROTECT_CLEANUP_ACTIONS, \
   LANG_HOOKS_EH_USE_CXA_END_CLEANUP, \
-  LANG_HOOKS_DEEP_UNSHARING \
+  LANG_HOOKS_DEEP_UNSHARING, \
+  LANG_HOOKS_PPH_CATCH_TREE, \
+  LANG_HOOKS_PPH_UNCATCH_TREE, \
 }
 
 #endif /* GCC_LANG_HOOKS_DEF_H */