Message ID | 20130823123756.GE4968@redhat.com |
---|---|
State | New |
Headers | show |
On Fri, Aug 23, 2013 at 02:37:56PM +0200, Marek Polacek wrote: > This patch fixes bootstrap comparison when doing bootstrap > with -fsanitize=undefined enabled. We need to hash the UID of the > type and also I had to switch two statements; we need to get > TYPE_MAIN_VARIANT of the type first... > Hence, no more bootstrap comparison failures. Woohoo! > > Tested x86_64-linux, applying to the ubsan branch. > > 2013-08-23 Marek Polacek <polacek@redhat.com> > > * ubsan.c (ubsan_typedesc_hasher::hash): Hash the TYPE_UID of the > type. > (ubsan_type_descriptor): Get TYPE_MAIN_VARIANT before initializing > the type descriptor. > > --- gcc/ubsan.c.mp 2013-08-23 14:28:15.780955545 +0200 > +++ gcc/ubsan.c 2013-08-23 14:28:47.467059363 +0200 > @@ -60,7 +60,7 @@ struct ubsan_typedesc_hasher > inline hashval_t > ubsan_typedesc_hasher::hash (const ubsan_typedesc *data) > { > - return iterative_hash_object (data->type, 0); > + return iterative_hash_object (TYPE_UID (data->type), 0); Why not just return TYPE_UID (data->type); ? Anyway, once you change the hash table uses into pointer_map, this will all go away. Jakub
On Fri, Aug 23, 2013 at 02:44:49PM +0200, Jakub Jelinek wrote: > Why not just return TYPE_UID (data->type); ? Wasn't aware it's enough. > Anyway, once you change the hash table uses into pointer_map, this will > all go away. Right. Marek
--- gcc/ubsan.c.mp 2013-08-23 14:28:15.780955545 +0200 +++ gcc/ubsan.c 2013-08-23 14:28:47.467059363 +0200 @@ -60,7 +60,7 @@ struct ubsan_typedesc_hasher inline hashval_t ubsan_typedesc_hasher::hash (const ubsan_typedesc *data) { - return iterative_hash_object (data->type, 0); + return iterative_hash_object (TYPE_UID (data->type), 0); } /* Compare two data types. */ @@ -298,11 +298,11 @@ ubsan_type_descriptor (tree type) { hash_table <ubsan_typedesc_hasher> ht = get_typedesc_hash_table (); ubsan_typedesc d; - ubsan_typedesc_init (&d, type, NULL); /* See through any typedefs. */ type = TYPE_MAIN_VARIANT (type); + ubsan_typedesc_init (&d, type, NULL); ubsan_typedesc **slot = ht.find_slot (&d, INSERT); if (*slot != NULL) /* We have the VAR_DECL in the table. Return it. */