===================================================================
@@ -27,12 +27,8 @@ along with GCC; see the file COPYING3. If not see
be global because it needs to be initialized in the C++ front end, but
used in the middle end (in the vtable verification pass). */
-extern tree verify_vtbl_ptr_fndecl;
+extern GTY(()) tree verify_vtbl_ptr_fndecl;
-/* Global variable keeping track of how many vtable map variables we
- have created. */
-extern unsigned num_vtable_map_nodes;
-
/* Keep track of how many virtual calls we are actually verifying. */
extern int total_num_virtual_calls;
extern int total_num_verified_vcalls;
@@ -127,10 +123,6 @@ extern bool vtv_debug;
/* The global vector of vtbl_map_nodes. */
extern vec<struct vtbl_map_node *> vtbl_map_nodes_vec;
-/* The global vectors for mangled class names for anonymous classes. */
-extern GTY(()) vec<tree, va_gc> *vtbl_mangled_name_types;
-extern GTY(()) vec<tree, va_gc> *vtbl_mangled_name_ids;
-
extern void vtbl_register_mangled_name (tree, tree);
extern struct vtbl_map_node *vtbl_map_get_node (tree);
extern struct vtbl_map_node *find_or_create_vtbl_map_node (tree);
===================================================================
@@ -144,11 +144,13 @@ along with GCC; see the file COPYING3. If not see
#include "vtable-verify.h"
-unsigned num_vtable_map_nodes = 0;
+/* Global variable keeping track of how many vtable map variables we
+ have created. */
+static unsigned num_vtable_map_nodes = 0;
+
int total_num_virtual_calls = 0;
int total_num_verified_vcalls = 0;
-extern GTY(()) tree verify_vtbl_ptr_fndecl;
tree verify_vtbl_ptr_fndecl = NULL_TREE;
/* Keep track of whether or not any virtual call were verified. */
@@ -305,10 +307,8 @@ static vtbl_map_table_type *vtbl_map_hash;
vec<struct vtbl_map_node *> vtbl_map_nodes_vec;
/* Vector of mangled names for anonymous classes. */
-extern GTY(()) vec<tree, va_gc> *vtbl_mangled_name_types;
-extern GTY(()) vec<tree, va_gc> *vtbl_mangled_name_ids;
-vec<tree, va_gc> *vtbl_mangled_name_types;
-vec<tree, va_gc> *vtbl_mangled_name_ids;
+static GTY(()) vec<tree, va_gc> *vtbl_mangled_name_types;
+static GTY(()) vec<tree, va_gc> *vtbl_mangled_name_ids;
/* Look up class_type (a type decl for record types) in the vtbl_mangled_names_*
vectors. This is a linear lookup. Return the associated mangled name for
===================================================================
@@ -137,8 +137,6 @@ struct work_node {
struct work_node *next;
};
-struct vtbl_map_node *vtable_find_or_create_map_decl (tree);
-
/* As part of vtable verification the compiler generates and inserts
calls to __VLTVerifyVtablePointer, which is in libstdc++. This
function builds and initializes the function decl that is used
@@ -380,7 +378,7 @@ void
vtv_compute_class_hierarchy_transitive_closure (void)
{
struct work_node *worklist = NULL;
- sbitmap inserted = sbitmap_alloc (num_vtable_map_nodes);
+ sbitmap inserted = sbitmap_alloc (vtbl_map_nodes_vec.length()); /* ??? leak? */
unsigned i;
unsigned j;
@@ -394,9 +392,9 @@ vtv_compute_class_hierarchy_transitive_closure (vo
/* Set-up: */
/* Find all the "leaf" nodes in the graph, and add them to the worklist. */
bitmap_clear (inserted);
- for (j = 0; j < num_vtable_map_nodes; ++j)
+ struct vtbl_map_node *cur;
+ for (j = 0; vtbl_map_nodes_vec.iterate (j, &cur); ++j)
{
- struct vtbl_map_node *cur = vtbl_map_nodes_vec[j];
if (cur->class_info
&& ((cur->class_info->children).length() == 0)
&& ! (bitmap_bit_p (inserted, cur->class_info->class_uid)))
@@ -412,7 +410,7 @@ vtv_compute_class_hierarchy_transitive_closure (vo
find_and_remove_next_leaf_node (&worklist);
gcc_assert (temp_node != NULL);
- temp_node->descendants = sbitmap_alloc (num_vtable_map_nodes);
+ temp_node->descendants = sbitmap_alloc (vtbl_map_nodes_vec.length()); /* ??? leak? */
bitmap_clear (temp_node->descendants);
bitmap_set_bit (temp_node->descendants, temp_node->class_uid);
for (i = 0; i < (temp_node->children).length(); ++i)
@@ -651,7 +649,7 @@ guess_num_vtable_pointers (struct vtv_graph_node *
int num_vtbls_power_of_two = 1;
unsigned i;
- for (i = 0; i < num_vtable_map_nodes; ++i)
+ for (i = 0; i < vtbl_map_nodes_vec.length (); ++i)
if (bitmap_bit_p (class_node->descendants, i))
{
tree class_type = vtbl_map_nodes_vec[i]->class_info->class_type;
@@ -901,10 +899,10 @@ register_all_pairs (tree body)
bool registered_at_least_one = false;
vec<tree> *vtbl_ptr_array = NULL;
unsigned j;
+ struct vtbl_map_node *current;
- for (j = 0; j < num_vtable_map_nodes; ++j)
+ for (j = 0; vtbl_map_nodes_vec.iterate (j, ¤t); ++j)
{
- struct vtbl_map_node *current = vtbl_map_nodes_vec[j];
unsigned i = 0;
tree base_class = current->class_info->class_type;
tree base_ptr_var_decl = current->vtbl_map_decl;
@@ -931,7 +929,7 @@ register_all_pairs (tree body)
vec_alloc (vtbl_ptr_array, 10);
- for (i = 0; i < num_vtable_map_nodes; ++i)
+ for (i = 0; i < vtbl_map_nodes_vec.length (); ++i)
if (bitmap_bit_p (current->class_info->descendants, i))
{
struct vtbl_map_node *vtbl_class_node = vtbl_map_nodes_vec[i];
@@ -1110,9 +1108,9 @@ write_out_vtv_count_data (void)
return;
}
- for (unsigned i = 0; i < num_vtable_map_nodes; ++i)
+ struct vtbl_map_node *current;
+ for (unsigned i = 0; vtbl_map_nodes_vec.iterate (i, ¤t); ++i)
{
- struct vtbl_map_node *current = vtbl_map_nodes_vec[i];
if (!current->is_used
&& current->registered->size() == 0)
unused_vtbl_map_vars++;
@@ -1141,7 +1139,7 @@ vtv_register_class_hierarchy_information (tree ini
init_functions ();
- if (num_vtable_map_nodes == 0)
+ if (vtbl_map_nodes_vec.length () == 0)
return false;
/* Add class hierarchy pairs to the vtable map data structure. */
@@ -1204,7 +1202,7 @@ vtv_generate_init_routine (void)
this process it also creates the global vtable map variable for the
class. */
-struct vtbl_map_node *
+static struct vtbl_map_node *
vtable_find_or_create_map_decl (tree base_type)
{
char *var_name = NULL;