From patchwork Fri Aug 23 12:37:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 269442 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 00B7A2C0084 for ; Fri, 23 Aug 2013 22:38:12 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=U/VdZavWHxlIPw81pSqZqmdDa5AMei+4JtGinv+Uy9bZd275qy77V TMy6pccmSgNuU460rGT63XNHXlOcrJnuFC3AdGgVX8d06jSw6G0VPhGdOTob4Zvx /SUn6as4iTMrtyOqy/BvpzBSZWPClJivJg0Wxs6gd6mNVml97GP2F8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=h6818lEflAKM8gGX8AUnFAsHG40=; b=TmBSUI1u0jKWjPzdj4Hh O/oCkxkCLxF4/pApqsaiCnQYOych9jbjaJT9Wj6x3M3W2LZyZUdSc+cK1zE9lvZ8 IWXDLPdFjFPzurRkm6jFaZZo0VbbcBAloTq7XRYmA+ip/RvQdWFcjxOQunRlLNfK KSbw3wMrTIOn8YlBy+oq6yQ= Received: (qmail 15189 invoked by alias); 23 Aug 2013 12:38:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 15171 invoked by uid 89); 23 Aug 2013 12:38:01 -0000 X-Spam-SWARE-Status: No, score=-7.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 23 Aug 2013 12:38:01 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7NCbxp1030979 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 23 Aug 2013 08:37:59 -0400 Received: from redhat.com (ovpn-116-91.ams2.redhat.com [10.36.116.91]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r7NCbu7f029706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Fri, 23 Aug 2013 08:37:59 -0400 Date: Fri, 23 Aug 2013 14:37:56 +0200 From: Marek Polacek To: GCC Patches Subject: [ubsan] Fix bootstrap comparison Message-ID: <20130823123756.GE4968@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 * 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. 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 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. */