On 12/2/20 9:19 AM, Nathan Sidwell wrote:
This is modified from the original patch.  firstly it contains a few more necessary bits.  But mainly I renamed the entities from 'MODULE_foo' to 'BINDING_foo', as it's a vector of bindings used by modules (not a vector of modules).  It also belongs in name-lookup.h.

Pushing to trunk

This adds the vector necessary to hold different module's namespace
bindings.  We add a new tree-node 'tree_binding_vec', which contains a
sparse array, indexed by module number.  To avoid space    wasting, this
is allocated in clusters using 'unsigned short'    as the index value (so
that's one of the upper bounds on module importing).  If there are
only bindings from the current TU, there is no vector, so we have the
same representation as a non-module compilation.

To support lazy    loading, a binding slot    can contain either a tree (the
binding), or a cookie that the module machinery uses to load the
required binding on demand.

The first 2 or 3 slots end up being reserved for fixed meanings.
There are a couple of flags we have to record on a binding, to know
whether the same declaration could appear in two different slots.

         gcc/cp/
     * cp-tree.def (BINDING_VECTOR): New.
     * name-lookup.h (struct binding_slot): New.
     (BINDING_VECTOR_SLOTS_PER_CLUSTER): New.
     (struct binding_index, struct binding_cluster): New.
     (BINDING_VECTOR_ALLOC_CLUSTERS, BINDING_VECTOR_CLUSTER_BASE)
     (BINDING_VECTOR_CLUSTER): New.
     (struct tree_binding_vec): New.
     (BINDING_VECTOR_NAME, BINDING_VECTOR_GLOBAL_DUPS_P)
     (BINDING_VECTOR_PARTITION_DUPS_P): New.
     (BINDING_BINDING_GLOBAL_P, BINDING_BINDING_PARTITION_P): New.
     (BINDING_VECTOR_PENDING_SPECIALIZATIONS)
     (BINDING_VECTOR_PENDING_IS_HEADER_P)
     (BINDING_VECTOR_PENDING_IS_PARTITION_P): New.
     * cp-tree.h (enum cp_tree_node_structure_enum): Add
     TS_CP_BINDING_VECTOR.
     (union lang_tree_node): Add binding_vec field.
     (make_binding_vec): Declare.
     (named_decl_hash::hash, named_decl_hash::equal): Check for binding
     vector.
     * decl.c (cp_tree_node_structure): Add BINDING_VECTOR case.
     * ptree.c (cxx_print_xnode): Add BINDING_VECTOR case.
     * tree.c (make_binding_vec): New.
...
+extern tree make_binding_vec                   (tree, unsigned clusters);
...
+make_binding_vec (tree name, unsigned clusters MEM_STAT_DECL)

You need the MEM_STAT decoration on the declaration as well, or building with --enable-gather-detailed-mem-stats breaks.
>From 84028ac50bd660b33b68bf91b11c38341e9c9bcc Mon Sep 17 00:00:00 2001
From: Jason Merrill <ja...@redhat.com>
Date: Fri, 11 Dec 2020 14:35:20 -0500
Subject: [PATCH] c++: Fix build with --enable-gather-detailed-mem-stats.

Nathan's recent patch added make_binding_vec defined with MEM_STAT_DECL, but
didn't add the parallel decoration to the forward declaration.

gcc/cp/ChangeLog:

	* cp-tree.h (make_binding_vec): Add CXX_MEM_STAT_INFO.
---
 gcc/cp/cp-tree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 5cd2999ca85..040c2113526 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -7621,7 +7621,7 @@ extern tree hash_tree_cons			(tree, tree, tree);
 extern tree hash_tree_chain			(tree, tree);
 extern tree build_qualified_name		(tree, tree, tree, bool);
 extern tree build_ref_qualified_type		(tree, cp_ref_qualifier);
-extern tree make_binding_vec			(tree, unsigned clusters);
+extern tree make_binding_vec			(tree, unsigned clusters CXX_MEM_STAT_INFO);
 inline tree ovl_first				(tree) ATTRIBUTE_PURE;
 extern tree ovl_make				(tree fn,
 						 tree next = NULL_TREE);
-- 
2.27.0

Reply via email to