This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to add template hash table statistics to -fstats
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 07 Apr 2010 11:36:17 -0400
- Subject: 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 <jason@redhat.com>
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)
ggc_free);
}
+/* Print stats about the template hash tables for -fstats. */
+
+void
+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 ();
#ifdef GATHER_STATISTICS
fprintf (stderr, "maximum template instantiation depth reached: %d\n",
depth_reached);