From patchwork Tue Jun 23 14:45:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 487665 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 79031140082 for ; Wed, 24 Jun 2015 00:45:58 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ptZ43p8c; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=xEq EahoYrXpHwv+6dzk1acNvuiwI64UoNtw/5WoxsDty6+dQqpby59IO/m+evhSKyrh Z+1Vm5D3TWXAHPncrVVFc4GRzBWkpL7Dapf6whfWgqWq3JgOqftrDko9380rLLi/ Q1sErp/gISP3RKTxEX0DijhynBHpWCvIfeLgdXEE= 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:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=default; bh=TeM9IWNd6 L5GYcsHM0YOHhBcvRc=; b=ptZ43p8cfLGtwLLUaEOpm4k4lIJCOT0eJGaByCFgp eUQNf2ZpA5UW4fmh+PlpdGeZidiHfq0LcJiu0pYGvXwEp2umv8CR7ttmEayrYUQx wWf8HI8LNhAAn8LlYtOz0MOqcdXvI1oyPJ8GZCVsJZVX2UT+bRJaT+1mUxmE39EM e4= Received: (qmail 11303 invoked by alias); 23 Jun 2015 14:45:51 -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 11293 invoked by uid 89); 23 Jun 2015 14:45:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=no version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Jun 2015 14:45:50 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-23--2TueZxJQBGXU8DSasJCIg-1 Received: from localhost ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 23 Jun 2015 15:45:46 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [03/12] Move decl hasher to header file References: <87egl2bicm.fsf@e105548-lin.cambridge.arm.com> Date: Tue, 23 Jun 2015 15:45:46 +0100 In-Reply-To: <87egl2bicm.fsf@e105548-lin.cambridge.arm.com> (Richard Sandiford's message of "Tue, 23 Jun 2015 15:38:17 +0100") Message-ID: <87wpyua3fp.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: -2TueZxJQBGXU8DSasJCIg-1 Like the previous patch, but for decl hashers. There's only one copy of this so far, but the idea seems general. gcc/ * tree-hash-traits.h (tree_decl_hash): New class. * tree-ssa-strlen.c: Include tree-hash-traits.h. (stridxlist_hash_traits): Use tree_decl_hash. Index: gcc/tree-hash-traits.h =================================================================== --- gcc/tree-hash-traits.h 2015-06-23 15:45:22.993947116 +0100 +++ gcc/tree-hash-traits.h 2015-06-23 15:45:22.989947161 +0100 @@ -39,4 +39,18 @@ tree_operand_hash::equal_keys (const_tre return operand_equal_p (t1, t2, 0); } +/* Hasher for tree decls. Pointer equality is enough here, but the DECL_UID + is a better hash than the pointer value and gives a predictable traversal + order. */ +struct tree_decl_hash : ggc_ptr_hash +{ + static inline hashval_t hash (tree); +}; + +inline hashval_t +tree_decl_hash::hash (tree t) +{ + return DECL_UID (t); +} + #endif Index: gcc/tree-ssa-strlen.c =================================================================== --- gcc/tree-ssa-strlen.c 2015-06-23 15:45:22.993947116 +0100 +++ gcc/tree-ssa-strlen.c 2015-06-23 15:45:22.989947161 +0100 @@ -73,6 +73,7 @@ the Free Software Foundation; either ver #include "ipa-ref.h" #include "cgraph.h" #include "ipa-chkp.h" +#include "tree-hash-traits.h" /* A vector indexed by SSA_NAME_VERSION. 0 means unknown, positive value is an index into strinfo vector, negative value stands for @@ -155,20 +156,7 @@ struct decl_stridxlist_map struct stridxlist list; }; -/* stridxlist hashtable helpers. */ - -struct stridxlist_hash_traits : default_hashmap_traits -{ - static inline hashval_t hash (tree); -}; - -/* Hash a from tree in a decl_stridxlist_map. */ - -inline hashval_t -stridxlist_hash_traits::hash (tree item) -{ - return DECL_UID (item); -} +typedef simple_hashmap_traits stridxlist_hash_traits; /* Hash table for mapping decls to a chained list of offset -> idx mappings. */