This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: Do more work when building a PCH


This patch squeezes another 0.4% percent out of Qt build times by
doing more work when building a PCH, and, therefore, less in each file
using the PCH.  These changes also avoid reduce the number of writes
to the PCH, which avoids copy-on-write faults.  There are more places
that node_decl_for_pch could be used, and more things that it could
do; as we find places for which it is measurably worthwhile, we can
add those.

Tested on i686-pc-linux-gnu, applied on the mainline.
  
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-12-19  Mark Mitchell  <mark@codesourcery.com>

	* cp-tree.h (note_decl_for_pch): New function.
	* class.c (build_clone): Call note_decl_for_pch.
	* semantics.c (finish_member_declaration): Likewise.
	(note_decl_for_pch): New function.

Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.695
diff -c -5 -p -r1.695 class.c
*** class.c	16 Dec 2004 11:03:13 -0000	1.695
--- class.c	20 Dec 2004 02:22:00 -0000
*************** build_clone (tree fn, tree name)
*** 3782,3791 ****
--- 3782,3793 ----
  	= build_clone (DECL_TEMPLATE_RESULT (clone), name);
        result = DECL_TEMPLATE_RESULT (clone);
        DECL_TEMPLATE_INFO (result) = copy_node (DECL_TEMPLATE_INFO (result));
        DECL_TI_TEMPLATE (result) = clone;
      }
+   else if (pch_file)
+     note_decl_for_pch (clone);
  
    return clone;
  }
  
  /* Produce declarations for all appropriate clones of FN.  If
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.1081
diff -c -5 -p -r1.1081 cp-tree.h
*** cp-tree.h	16 Dec 2004 11:03:17 -0000	1.1081
--- cp-tree.h	20 Dec 2004 02:22:00 -0000
*************** extern tree check_template_template_defa
*** 4185,4194 ****
--- 4185,4195 ----
  extern void expand_or_defer_fn			(tree);
  extern void check_accessibility_of_qualified_id (tree, tree, tree);
  extern tree finish_qualified_id_expr            (tree, tree, bool, bool);
  extern void simplify_aggr_init_expr		(tree *);
  extern void finalize_nrv			(tree *, tree, tree);
+ extern void note_decl_for_pch                   (tree);
  
  /* in tree.c */
  extern void lang_check_failed			(const char *, int,
  							 const char *);
  extern tree stabilize_expr			(tree, tree *);
Index: semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.452
diff -c -5 -p -r1.452 semantics.c
*** semantics.c	8 Dec 2004 08:35:45 -0000	1.452
--- semantics.c	20 Dec 2004 02:22:01 -0000
*************** finish_member_declaration (tree decl)
*** 2224,2233 ****
--- 2224,2267 ----
  	}
  
        maybe_add_class_template_decl_list (current_class_type, decl, 
  					  /*friend_p=*/0);
      }
+ 
+   if (pch_file)
+     note_decl_for_pch (decl);
+ }
+ 
+ /* DECL has been declared while we are building a PCH file.  Perform
+    actions that we might normally undertake lazily, but which can be
+    performed now so that they do not have to be performed in
+    translation units which include the PCH file.  */
+ 
+ void
+ note_decl_for_pch (tree decl)
+ {
+   gcc_assert (pch_file);
+ 
+   /* A non-template inline function with external linkage will always
+      be COMDAT.  As we must eventually determine the linkage of all
+      functions, and as that causes writes to the data mapped in from
+      the PCH file, it's advantageous to mark the functions at this
+      point.  */
+   if (TREE_CODE (decl) == FUNCTION_DECL
+       && TREE_PUBLIC (decl)
+       && DECL_DECLARED_INLINE_P (decl)
+       && !DECL_IMPLICIT_INSTANTIATION (decl))
+     {
+       comdat_linkage (decl);
+       DECL_INTERFACE_KNOWN (decl) = 1;
+     }
+   
+   /* There's a good chance that we'll have to mangle names at some
+      point, even if only for emission in debugging information.  */
+   if (TREE_CODE (decl) == VAR_DECL
+       || TREE_CODE (decl) == FUNCTION_DECL)
+     mangle_decl (decl);
  }
  
  /* Finish processing a complete template declaration.  The PARMS are
     the template parameters.  */
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]