summaryrefslogtreecommitdiff
path: root/gcc/coverage.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/coverage.c')
-rw-r--r--gcc/coverage.c50
1 files changed, 20 insertions, 30 deletions
diff --git a/gcc/coverage.c b/gcc/coverage.c
index af522891110..3fea525a08d 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -43,7 +43,7 @@ along with GCC; see the file COPYING3. If not see
#include "ggc.h"
#include "coverage.h"
#include "langhooks.h"
-#include "hashtab.h"
+#include "hash-table.h"
#include "tree-iterator.h"
#include "cgraph.h"
#include "dumpfile.h"
@@ -109,17 +109,11 @@ static unsigned bbg_file_stamp;
/* Name of the count data (gcda) file. */
static char *da_file_name;
-/* Hash table of count data. */
-static htab_t counts_hash = NULL;
-
/* The names of merge functions for counters. */
static const char *const ctr_merge_functions[GCOV_COUNTERS] = GCOV_MERGE_FUNCTIONS;
static const char *const ctr_names[GCOV_COUNTERS] = GCOV_COUNTER_NAMES;
/* Forward declarations. */
-static hashval_t htab_counts_entry_hash (const void *);
-static int htab_counts_entry_eq (const void *, const void *);
-static void htab_counts_entry_del (void *);
static void read_counts_file (void);
static tree build_var (tree, tree, int);
static void build_fn_info_type (tree, unsigned, tree);
@@ -149,32 +143,31 @@ get_gcov_unsigned_t (void)
return lang_hooks.types.type_for_mode (mode, true);
}
-static hashval_t
-htab_counts_entry_hash (const void *of)
+inline hashval_t
+coverage_counts_entry_hash (const counts_entry_t *entry)
{
- const counts_entry_t *const entry = (const counts_entry_t *) of;
-
return entry->ident * GCOV_COUNTERS + entry->ctr;
}
-static int
-htab_counts_entry_eq (const void *of1, const void *of2)
+inline int
+coverage_counts_entry_eq (const counts_entry_t *entry1,
+ const counts_entry_t *entry2)
{
- const counts_entry_t *const entry1 = (const counts_entry_t *) of1;
- const counts_entry_t *const entry2 = (const counts_entry_t *) of2;
-
return entry1->ident == entry2->ident && entry1->ctr == entry2->ctr;
}
-static void
-htab_counts_entry_del (void *of)
+inline void
+coverage_counts_entry_del (counts_entry_t *entry)
{
- counts_entry_t *const entry = (counts_entry_t *) of;
-
free (entry->counts);
free (entry);
}
+/* Hash table of count data. */
+static hash_table <counts_entry_t, coverage_counts_entry_hash,
+ coverage_counts_entry_eq, coverage_counts_entry_del>
+ counts_hash;
+
/* Read in the counts file, if available. */
static void
@@ -214,9 +207,7 @@ read_counts_file (void)
tag = gcov_read_unsigned ();
bbg_file_stamp = crc32_unsigned (bbg_file_stamp, tag);
- counts_hash = htab_create (10,
- htab_counts_entry_hash, htab_counts_entry_eq,
- htab_counts_entry_del);
+ counts_hash.create (10);
while ((tag = gcov_read_unsigned ()))
{
gcov_unsigned_t length;
@@ -264,8 +255,7 @@ read_counts_file (void)
elt.ident = fn_ident;
elt.ctr = GCOV_COUNTER_FOR_TAG (tag);
- slot = (counts_entry_t **) htab_find_slot
- (counts_hash, &elt, INSERT);
+ slot = counts_hash.find_slot (&elt, INSERT);
entry = *slot;
if (!entry)
{
@@ -285,14 +275,14 @@ read_counts_file (void)
error ("checksum is (%x,%x) instead of (%x,%x)",
entry->lineno_checksum, entry->cfg_checksum,
lineno_checksum, cfg_checksum);
- htab_delete (counts_hash);
+ counts_hash.dispose ();
break;
}
else if (entry->summary.num != n_counts)
{
error ("Profile data for function %u is corrupted", fn_ident);
error ("number of counters is %d instead of %d", entry->summary.num, n_counts);
- htab_delete (counts_hash);
+ counts_hash.dispose ();
break;
}
else if (elt.ctr >= GCOV_COUNTERS_SUMMABLE)
@@ -318,7 +308,7 @@ read_counts_file (void)
{
error (is_error < 0 ? "%qs has overflowed" : "%qs is corrupted",
da_file_name);
- htab_delete (counts_hash);
+ counts_hash.dispose ();
break;
}
}
@@ -336,7 +326,7 @@ get_coverage_counts (unsigned counter, unsigned expected,
counts_entry_t *entry, elt;
/* No hash table, no counts. */
- if (!counts_hash)
+ if (!counts_hash.is_created ())
{
static int warned = 0;
@@ -350,7 +340,7 @@ get_coverage_counts (unsigned counter, unsigned expected,
elt.ident = current_function_funcdef_no + 1;
elt.ctr = counter;
- entry = (counts_entry_t *) htab_find (counts_hash, &elt);
+ entry = counts_hash.find (&elt);
if (!entry || !entry->summary.num)
/* The function was not emitted, or is weak and not chosen in the
final executable. Silently fail, because there's nothing we