From patchwork Wed Aug 28 12:15:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 270486 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 "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 058242C00B3 for ; Wed, 28 Aug 2013 22:15:56 +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:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=uUYBNhqP2nuoaSion cIEUH6adRK8XMXbcn7wwOHXLbq+PfECJJqQ7CEtDzi0gkJgMPUAkurZp1z22KjGf HUgKrQyeKfBR3LK+YJ5CDoXDJYgQeLzn5E7PpmLQPbRyqOVZId7i+EHepy0Nbxyg CfH8udkD93ewHyNhJxEyrcSCgQ= 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:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=9lHgmMHAI579INYrZMKede5 Zrw4=; b=ZpA3QtG6uSsNT/Ka4SlkmGYE/pORjBpl0WPpQt++AsOgfN1ryrz2qoH yC2/cKnjjL7N1xKAk6Ob9ugCBfyx7kcXgHGVjpkWU8CfU++tCICDEfiUCZqBce7n 0Rq9v9aI+1u790YIg1uFWL4Lq4QIi+lHdsXi4i7yZR7FvxNJZTtQ= Received: (qmail 14005 invoked by alias); 28 Aug 2013 12:15:50 -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 13996 invoked by uid 89); 28 Aug 2013 12:15:50 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Aug 2013 12:15:50 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7SCFlc2003034 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Aug 2013 08:15:47 -0400 Received: from redhat.com (ovpn-116-91.ams2.redhat.com [10.36.116.91]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r7SCFiBF022755 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 28 Aug 2013 08:15:46 -0400 Date: Wed, 28 Aug 2013 14:15:43 +0200 From: Marek Polacek To: Richard Biener Cc: GCC Patches , Jakub Jelinek Subject: Re: [ubsan] Use pointer map instead of hash table. Message-ID: <20130828121543.GD574@redhat.com> References: <20130827123338.GA574@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) On Wed, Aug 28, 2013 at 12:40:50PM +0200, Richard Biener wrote: > On Tue, Aug 27, 2013 at 2:33 PM, Marek Polacek wrote: > > It turned out that for tree -> tree mapping we don't need the hash > > table at all; pointer map is much more convenient. So this patch > > weeds out the hash table out of ubsan and introduces pointer map > > instead. Quite a lot of code could go away--no need to set the > > alloc pools up etc. > > > > Regtested, ran bootstrap-ubsan on x86_64-linux. Applying to the > > ubsan branch. > > You can use the type-safe pointer_map now (ok, only the data type > is type safe, the pointer is still void). Thanks, done with the following. Please let me know if you see something wrong in this; otherwise I'll commit it if the bootstrap-ubsan passes. 2013-08-28 Marek Polacek * ubsan.c: Use pointer_map instead of pointer_map_t. (insert_decl_for_type): Adjust. (lookup_decl_for_type): Likewise. Marek --- gcc/ubsan.c.mp 2013-08-28 12:54:17.778383224 +0200 +++ gcc/ubsan.c 2013-08-28 14:09:42.400105470 +0200 @@ -31,16 +31,14 @@ along with GCC; see the file COPYING3. #include "c-family/c-common.h" /* Map a TYPE to an ubsan type descriptor VAR_DECL for that type. */ -static pointer_map_t *typedesc_map; +static pointer_map *typedesc_map; /* Insert DECL as the VAR_DECL for TYPE in the TYPEDESC_MAP. */ static void insert_decl_for_type (tree decl, tree type) { - void **slot = pointer_map_insert (typedesc_map, type); - gcc_assert (*slot == NULL); - *slot = decl; + *typedesc_map->insert (type) = decl; } /* Find the VAR_DECL for TYPE in TYPEDESC_MAP. If TYPE does not @@ -52,9 +50,13 @@ lookup_decl_for_type (tree type) { /* If the pointer map is not initialized yet, create it now. */ if (typedesc_map == NULL) - typedesc_map = pointer_map_create (); - void **slot = pointer_map_contains (typedesc_map, type); - return slot ? (tree) *slot : NULL_TREE; + { + typedesc_map = new pointer_map; + /* That also means we don't have to bother with the lookup. */ + return NULL_TREE; + } + tree *t = typedesc_map->contains (type); + return t ? *t : NULL_TREE; } /* Helper routine, which encodes a value in the pointer_sized_int_node.