summaryrefslogtreecommitdiff
path: root/gcc/cfg.c
diff options
context:
space:
mode:
authorcrowl <crowl@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-09 21:21:36 +0000
committercrowl <crowl@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-09 21:21:36 +0000
commitd1455aa3757cdf92c69e09e9d5fc8914257809c6 (patch)
tree6b83efb5a5d730e31c6760ce9e20be32071b13a4 /gcc/cfg.c
parent981934828da13c50a4a58264cd6182664186dbb1 (diff)
downloadgcc-d1455aa3757cdf92c69e09e9d5fc8914257809c6.tar.gz
Change more non-GTY hash tables to use the new type-safe template hash table.
Constify member function parameters that can be const. Correct a couple of expressions in formerly uninstantiated templates. The new code is 0.362% faster in bootstrap, with a 99.5% confidence of being faster. Tested on x86-64. Index: gcc/java/ChangeLog 2012-10-01 Lawrence Crowl <crowl@google.com> * Make-lang.in (JAVA_OBJS): Add dependence on hash-table.o. (JCFDUMP_OBJS): Add dependence on hash-table.o. (jcf-io.o): Add dependence on hash-table.h. * jcf-io.c (memoized_class_lookups): Change to use type-safe hash table. Index: gcc/c/ChangeLog 2012-10-09 Lawrence Crowl <crowl@google.com> * Make-lang.in (c-decl.o): Add dependence on hash-table.h. * c-decl.c (detect_field_duplicates_hash): Change to new type-safe hash table. Index: gcc/objc/ChangeLog 2012-10-01 Lawrence Crowl <crowl@google.com> * Make-lang.in (OBJC_OBJS): Add dependence on hash-table.o. (objc-act.o): Add dependence on hash-table.h. * objc-act.c (objc_detect_field_duplicates): Change to new type-safe hash table. Index: gcc/ChangeLog 2012-10-09 Lawrence Crowl <crowl@google.com> * Makefile.in (fold-const.o): Add depencence on hash-table.h. (dse.o): Likewise. (cfg.o): Likewise. * fold-const.c (fold_checksum_tree): Change to new type-safe hash table. * (print_fold_checksum): Likewise. * cfg.c (var bb_original): Likewise. * (var bb_copy): Likewise. * (var loop_copy): Likewise. * hash-table.h (template hash_table): Constify parameters for find... and remove_elt... member functions. (hash_table::empty) Correct size expression. (hash_table::clear_slot) Correct deleted entry assignment. * dse.c (var rtx_group_table): Change to new type-safe hash table. Index: gcc/cp/ChangeLog 2012-10-09 Lawrence Crowl <crowl@google.com> * Make-lang.in (class.o): Add dependence on hash-table.h. (tree.o): Likewise. (semantics.o): Likewise. * class.c (fixed_type_or_null): Change to new type-safe hash table. * tree.c (verify_stmt_tree): Likewise. (verify_stmt_tree_r): Likewise. * semantics.c (struct nrv_data): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192273 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfg.c')
-rw-r--r--gcc/cfg.c81
1 files changed, 40 insertions, 41 deletions
diff --git a/gcc/cfg.c b/gcc/cfg.c
index eaf5863516f..f0b91e09492 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -53,7 +53,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "obstack.h"
#include "ggc.h"
-#include "hashtab.h"
+#include "hash-table.h"
#include "alloc-pool.h"
#include "tree.h"
#include "basic-block.h"
@@ -976,14 +976,7 @@ scale_bbs_frequencies_gcov_type (basic_block *bbs, int nbbs, gcov_type num,
}
}
-/* Data structures used to maintain mapping between basic blocks and
- copies. */
-static htab_t bb_original;
-static htab_t bb_copy;
-
-/* And between loops and copies. */
-static htab_t loop_copy;
-static alloc_pool original_copy_bb_pool;
+/* Helper types for hash tables. */
struct htab_bb_copy_original_entry
{
@@ -993,25 +986,35 @@ struct htab_bb_copy_original_entry
int index2;
};
-static hashval_t
-bb_copy_original_hash (const void *p)
+struct bb_copy_hasher : typed_noop_remove <htab_bb_copy_original_entry>
{
- const struct htab_bb_copy_original_entry *data
- = ((const struct htab_bb_copy_original_entry *)p);
+ typedef htab_bb_copy_original_entry T;
+ static inline hashval_t hash (const T *);
+ static inline bool equal (const T *existing, const T * candidate);
+};
+inline hashval_t
+bb_copy_hasher::hash (const T *data)
+{
return data->index1;
}
-static int
-bb_copy_original_eq (const void *p, const void *q)
-{
- const struct htab_bb_copy_original_entry *data
- = ((const struct htab_bb_copy_original_entry *)p);
- const struct htab_bb_copy_original_entry *data2
- = ((const struct htab_bb_copy_original_entry *)q);
+inline bool
+bb_copy_hasher::equal (const T *data, const T *data2)
+{
return data->index1 == data2->index1;
}
+/* Data structures used to maintain mapping between basic blocks and
+ copies. */
+static hash_table <bb_copy_hasher> bb_original;
+static hash_table <bb_copy_hasher> bb_copy;
+
+/* And between loops and copies. */
+static hash_table <bb_copy_hasher> loop_copy;
+static alloc_pool original_copy_bb_pool;
+
+
/* Initialize the data structures to maintain mapping between blocks
and its copies. */
void
@@ -1021,10 +1024,9 @@ initialize_original_copy_tables (void)
original_copy_bb_pool
= create_alloc_pool ("original_copy",
sizeof (struct htab_bb_copy_original_entry), 10);
- bb_original = htab_create (10, bb_copy_original_hash,
- bb_copy_original_eq, NULL);
- bb_copy = htab_create (10, bb_copy_original_hash, bb_copy_original_eq, NULL);
- loop_copy = htab_create (10, bb_copy_original_hash, bb_copy_original_eq, NULL);
+ bb_original.create (10);
+ bb_copy.create (10);
+ loop_copy.create (10);
}
/* Free the data structures to maintain mapping between blocks and
@@ -1033,34 +1035,31 @@ void
free_original_copy_tables (void)
{
gcc_assert (original_copy_bb_pool);
- htab_delete (bb_copy);
- htab_delete (bb_original);
- htab_delete (loop_copy);
+ bb_copy.dispose ();
+ bb_original.dispose ();
+ loop_copy.dispose ();
free_alloc_pool (original_copy_bb_pool);
- bb_copy = NULL;
- bb_original = NULL;
- loop_copy = NULL;
original_copy_bb_pool = NULL;
}
/* Removes the value associated with OBJ from table TAB. */
static void
-copy_original_table_clear (htab_t tab, unsigned obj)
+copy_original_table_clear (hash_table <bb_copy_hasher> tab, unsigned obj)
{
- void **slot;
+ htab_bb_copy_original_entry **slot;
struct htab_bb_copy_original_entry key, *elt;
if (!original_copy_bb_pool)
return;
key.index1 = obj;
- slot = htab_find_slot (tab, &key, NO_INSERT);
+ slot = tab.find_slot (&key, NO_INSERT);
if (!slot)
return;
- elt = (struct htab_bb_copy_original_entry *) *slot;
- htab_clear_slot (tab, slot);
+ elt = *slot;
+ tab.clear_slot (slot);
pool_free (original_copy_bb_pool, elt);
}
@@ -1068,7 +1067,8 @@ copy_original_table_clear (htab_t tab, unsigned obj)
Do nothing when data structures are not initialized. */
static void
-copy_original_table_set (htab_t tab, unsigned obj, unsigned val)
+copy_original_table_set (hash_table <bb_copy_hasher> tab,
+ unsigned obj, unsigned val)
{
struct htab_bb_copy_original_entry **slot;
struct htab_bb_copy_original_entry key;
@@ -1077,8 +1077,7 @@ copy_original_table_set (htab_t tab, unsigned obj, unsigned val)
return;
key.index1 = obj;
- slot = (struct htab_bb_copy_original_entry **)
- htab_find_slot (tab, &key, INSERT);
+ slot = tab.find_slot (&key, INSERT);
if (!*slot)
{
*slot = (struct htab_bb_copy_original_entry *)
@@ -1106,7 +1105,7 @@ get_bb_original (basic_block bb)
gcc_assert (original_copy_bb_pool);
key.index1 = bb->index;
- entry = (struct htab_bb_copy_original_entry *) htab_find (bb_original, &key);
+ entry = bb_original.find (&key);
if (entry)
return BASIC_BLOCK (entry->index2);
else
@@ -1131,7 +1130,7 @@ get_bb_copy (basic_block bb)
gcc_assert (original_copy_bb_pool);
key.index1 = bb->index;
- entry = (struct htab_bb_copy_original_entry *) htab_find (bb_copy, &key);
+ entry = bb_copy.find (&key);
if (entry)
return BASIC_BLOCK (entry->index2);
else
@@ -1161,7 +1160,7 @@ get_loop_copy (struct loop *loop)
gcc_assert (original_copy_bb_pool);
key.index1 = loop->num;
- entry = (struct htab_bb_copy_original_entry *) htab_find (loop_copy, &key);
+ entry = loop_copy.find (&key);
if (entry)
return get_loop (entry->index2);
else