This is the mail archive of the 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 to add template hash table statistics to -fstats

At one point I was interested in collision statistics for the (new to 4.5) template specialization hash tables, so I added them to -fstats.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit b0f5018f85cf8a926d364a343ee3f8e925a64129
Author: Jason Merrill <>
Date:   Wed Dec 16 12:04:04 2009 -0500

    	* pt.c (print_template_statistics): New.
    	* cp-tree.h: Declare it.
    	* tree.c (cxx_print_statistics): Call it.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 6334673..1350619 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4975,6 +4975,7 @@ extern void pop_tinst_level                     (void);
 extern struct tinst_level *outermost_tinst_level(void);
 extern bool parameter_of_template_p		(tree, tree);
 extern void init_template_processing		(void);
+extern void print_template_statistics		(void);
 bool template_template_parameter_p		(const_tree);
 extern bool primary_template_instantiation_p    (const_tree);
 extern tree get_primary_template_innermost_parameters	(const_tree);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 0bd55e1..052cc80 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18553,4 +18553,19 @@ init_template_processing (void)
+/* Print stats about the template hash tables for -fstats.  */
+print_template_statistics (void)
+  fprintf (stderr, "decl_specializations: size %ld, %ld elements, "
+	   "%f collisions\n", (long) htab_size (decl_specializations),
+	   (long) htab_elements (decl_specializations),
+	   htab_collisions (decl_specializations));
+  fprintf (stderr, "type_specializations: size %ld, %ld elements, "
+	   "%f collisions\n", (long) htab_size (type_specializations),
+	   (long) htab_elements (type_specializations),
+	   htab_collisions (type_specializations));
 #include "gt-cp-pt.h"
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 35b0da6..27ced53 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1664,6 +1664,7 @@ cxx_print_statistics (void)
   print_search_statistics ();
   print_class_statistics ();
+  print_template_statistics ();
   fprintf (stderr, "maximum template instantiation depth reached: %d\n",

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