Do not hash the memory address of an isl_name
authorTobias Grosser <grosser@fim.uni-passau.de>
Fri, 17 Dec 2010 16:05:10 +0000 (11:05 -0500)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 17 Dec 2010 17:46:35 +0000 (18:46 +0100)
Hash the name string itself. This gives repeatable results on all platforms and will
therefore facilitate debugging.

Signed-off-by: Tobias Grosser <grosser@fim.uni-passau.de>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_dim.c
isl_name.c
isl_name.h

index 4b5d2c0..f6e6018 100644 (file)
--- a/isl_dim.c
+++ b/isl_dim.c
@@ -988,13 +988,13 @@ static uint32_t isl_hash_dim(uint32_t hash, __isl_keep isl_dim *dim)
 
        for (i = 0; i < dim->nparam; ++i) {
                name = get_name(dim, isl_dim_param, i);
-               hash = isl_hash_builtin(hash, name);
+               hash = isl_hash_name(hash, name);
        }
 
        name = tuple_name(dim, isl_dim_in);
-       hash = isl_hash_builtin(hash, name);
+       hash = isl_hash_name(hash, name);
        name = tuple_name(dim, isl_dim_out);
-       hash = isl_hash_builtin(hash, name);
+       hash = isl_hash_name(hash, name);
 
        hash = isl_hash_dim(hash, dim->nested[0]);
        hash = isl_hash_dim(hash, dim->nested[1]);
index 8e902db..4925c9b 100644 (file)
@@ -24,6 +24,9 @@ struct isl_name *isl_name_alloc(struct isl_ctx *ctx, const char *s)
        name->ref = 1;
        name->name = copy;
 
+       name->hash = isl_hash_init();
+       name->hash = isl_hash_string(name->hash, s);
+
        return name;
 error:
        free((char *)copy);
@@ -70,6 +73,14 @@ static int isl_name_eq(const void *entry, const void *name)
        return entry == name;
 }
 
+uint32_t isl_hash_name(uint32_t hash, struct isl_name *name)
+{
+       if (name)
+               isl_hash_hash(hash, name->hash);
+
+       return hash;
+}
+
 void isl_name_free(struct isl_ctx *ctx, struct isl_name *name)
 {
        uint32_t name_hash;
index 2910b76..3db7683 100644 (file)
@@ -20,11 +20,13 @@ struct isl_name {
        int ref;
 
        const char *name;
+       uint32_t hash;
 };
 
 struct isl_name *isl_name_alloc(struct isl_ctx *ctx, const char *name);
 struct isl_name *isl_name_get(struct isl_ctx *ctx, const char *name);
 struct isl_name *isl_name_copy(struct isl_ctx *ctx, struct isl_name *name);
+uint32_t isl_hash_name(uint32_t hash, struct isl_name *name);
 void isl_name_free(struct isl_ctx *ctx, struct isl_name *name);
 
 #if defined(__cplusplus)