This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix bootstrap failure on all 64-bit hosts


This patch fixes the "cast to pointer from integer of different size"
warnings which are causing bootstrap failures on all 64-bit hosts.
The hash table in question is never traversed, so there's no reason
not to use pointer hashing, and it oughta be a smidge more efficient.
And doesn't require nasty casts, either.

(Why is htab_hash_pointer a function pointer instead of an exported
symbol?  For that matter, why doesn't hashtab.h provide a macro, since
it is essentially "return x >> 3" ?)

Bootstrap on amd64-linux in progress (but has gotten past the point of
the original failure); will apply tomorrow morning if successful.

zw

        * cgraph.c (hash_node, eq_node, cgraph_node, cgraph_remove_node)
        (cgraph_varpool_hash_node, eq_cgraph_varpool_node)
        (cgraph_varpool_node): Hash on the pointer to the decl, not
        the DECL_UID.  Fixes 64-bit bootstrap failure.

===================================================================
Index: cgraph.c
--- cgraph.c	19 May 2004 01:28:49 -0000	1.50
+++ cgraph.c	20 May 2004 07:25:44 -0000
@@ -139,7 +139,7 @@ static int eq_node (const void *, const 
 static hashval_t
 hash_node (const void *p)
 {
-  return ((hashval_t) DECL_UID (((struct cgraph_node *) p)->decl));
+  return htab_hash_pointer (((struct cgraph_node *) p)->decl);
 }
 
 /* Returns nonzero if P1 and P2 are equal.  */
@@ -147,7 +147,7 @@ hash_node (const void *p)
 static int
 eq_node (const void *p1, const void *p2)
 {
-  return (DECL_UID (((struct cgraph_node *) p1)->decl) == (unsigned int)p2);
+  return (void *)((struct cgraph_node *) p1)->decl == p2;
 }
 
 /* Allocate new callgraph node and insert it into basic data structures.  */
@@ -181,10 +181,8 @@ cgraph_node (tree decl)
     cgraph_hash = htab_create_ggc (10, hash_node, eq_node, NULL);
 
   slot = (struct cgraph_node **)
-    htab_find_slot_with_hash (cgraph_hash,
-			      (void *)DECL_UID (decl),
-			      (hashval_t)DECL_UID (decl),
-			      INSERT);
+    htab_find_slot_with_hash (cgraph_hash, decl,
+			      htab_hash_pointer (decl), INSERT);
   if (*slot)
     return *slot;
 
@@ -326,10 +324,8 @@ cgraph_remove_node (struct cgraph_node *
   if (node->next)
     node->next->previous = node->previous;
   slot = 
-    htab_find_slot_with_hash (cgraph_hash,
-			      (void *)DECL_UID (node->decl),
-			      (hashval_t)DECL_UID (node->decl),
-			      NO_INSERT);
+    htab_find_slot_with_hash (cgraph_hash, node->decl,
+			      htab_hash_pointer (node->decl), NO_INSERT);
   if (*slot == node)
     {
       if (node->next_clone)
@@ -532,7 +528,7 @@ dump_cgraph (FILE *f)
 static hashval_t
 cgraph_varpool_hash_node (const void *p)
 {
-  return ((hashval_t) DECL_UID (((struct cgraph_varpool_node *) p)->decl));
+  return htab_hash_pointer (((struct cgraph_varpool_node *) p)->decl);
 }
 
 /* Returns nonzero if P1 and P2 are equal.  */
@@ -540,9 +536,7 @@ cgraph_varpool_hash_node (const void *p)
 static int
 eq_cgraph_varpool_node (const void *p1, const void *p2)
 {
-  return (DECL_UID (((struct cgraph_varpool_node *) p1)->decl)
-	  == (unsigned int) p2);
-
+  return (void *)((struct cgraph_varpool_node *) p1)->decl == p2;
 }
 
 /* Return cgraph_varpool node assigned to DECL.  Create new one when needed.  */
@@ -559,10 +553,8 @@ cgraph_varpool_node (tree decl)
     cgraph_varpool_hash = htab_create_ggc (10, cgraph_varpool_hash_node,
 				           eq_cgraph_varpool_node, NULL);
   slot = (struct cgraph_varpool_node **)
-    htab_find_slot_with_hash (cgraph_varpool_hash,
-			      (void *)DECL_UID (decl),
-			      (hashval_t)DECL_UID (decl),
-			      INSERT);
+    htab_find_slot_with_hash (cgraph_varpool_hash, decl,
+			      htab_hash_pointer (decl), INSERT);
   if (*slot)
     return *slot;
   node = ggc_alloc_cleared (sizeof (*node));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]