From patchwork Wed Jul 16 05:31:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 370592 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 254181400D5 for ; Wed, 16 Jul 2014 15:33:11 +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:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=Dx5B2Sfd67/hjKcLClokdR4RpLj238J/HevtynqcBZYC9UUF+wq3C 1RlR5HzOcSAxVZZ73XkczbDD0M1R+IuaHLGhKjRERfUgHaMv/XG1Q5/9wTpxMhPT RBpvR0Q51CFE+o2FfjhuSydoTunzlRfSSZTXdnzpcV3Ef5qSCjaiz4= 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:cc:subject:date:message-id:in-reply-to:references; s= default; bh=xLH9oaLmrKbKugdHFo1ugjzFYr0=; b=vfHQamTc6iBHFOjQZMsV V+e/K4zpTWM4COSmCE9m9ZQda65G2myMxCVbnkZ6m38QSeP6c/Kse25ZJ13ouaJn VYYPzgE53X+gxYQnh5L9y4SsO6nGWNTB5bqBRKg/D5iavsAmQBK1kLn/p346NJbZ 4QEGAI+zaVqcJomc4heWk8E= Received: (qmail 31351 invoked by alias); 16 Jul 2014 05:32: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 31262 invoked by uid 89); 16 Jul 2014 05:32:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: one.firstfloor.org Received: from one.firstfloor.org (HELO one.firstfloor.org) (193.170.194.197) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 16 Jul 2014 05:32:44 +0000 Received: from basil.firstfloor.org (184-100-237-164.ptld.qwest.net [184.100.237.164]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by one.firstfloor.org (Postfix) with ESMTPSA id D97028677F; Wed, 16 Jul 2014 07:32:38 +0200 (CEST) Received: by basil.firstfloor.org (Postfix, from userid 1000) id 44F31A1FC8; Tue, 15 Jul 2014 22:31:53 -0700 (PDT) From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH 2/4] Convert LTO type hashing to the new inchash interface Date: Tue, 15 Jul 2014 22:31:47 -0700 Message-Id: <1405488709-12677-3-git-send-email-andi@firstfloor.org> In-Reply-To: <1405488709-12677-2-git-send-email-andi@firstfloor.org> References: <1405488709-12677-1-git-send-email-andi@firstfloor.org> <1405488709-12677-2-git-send-email-andi@firstfloor.org> From: Andi Kleen Should not really change any behavior, it's just a more abstract interface, but uses the same underlying hash functions. lto/: 2014-07-10 Andi Kleen * lto.c (hash_canonical_type): Convert to inchash. (iterative_hash_canonical_type): Dito. --- gcc/lto/lto.c | 56 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index 300f569..eeb4f8a 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -267,7 +267,7 @@ static hash_map *canonical_type_hash_cache; static unsigned long num_canonical_type_hash_entries; static unsigned long num_canonical_type_hash_queries; -static hashval_t iterative_hash_canonical_type (tree type, hashval_t val); +static void iterative_hash_canonical_type (tree type, inchash &hstate); static hashval_t gimple_canonical_type_hash (const void *p); static void gimple_register_canonical_type_1 (tree t, hashval_t hash); @@ -279,14 +279,16 @@ static void gimple_register_canonical_type_1 (tree t, hashval_t hash); static hashval_t hash_canonical_type (tree type) { - hashval_t v; + inchash hstate; + + hstate.begin (); /* Combine a few common features of types so that types are grouped into smaller sets; when searching for existing matching types to merge, only existing types having the same features as the new type will be checked. */ - v = iterative_hash_hashval_t (TREE_CODE (type), 0); - v = iterative_hash_hashval_t (TYPE_MODE (type), v); + hstate.add_int (TREE_CODE (type)); + hstate.add_int (TYPE_MODE (type)); /* Incorporate common features of numerical types. */ if (INTEGRAL_TYPE_P (type) @@ -295,48 +297,50 @@ hash_canonical_type (tree type) || TREE_CODE (type) == OFFSET_TYPE || POINTER_TYPE_P (type)) { - v = iterative_hash_hashval_t (TYPE_PRECISION (type), v); - v = iterative_hash_hashval_t (TYPE_UNSIGNED (type), v); + hstate.add_int (TYPE_UNSIGNED (type)); + hstate.add_int (TYPE_PRECISION (type)); } if (VECTOR_TYPE_P (type)) { - v = iterative_hash_hashval_t (TYPE_VECTOR_SUBPARTS (type), v); - v = iterative_hash_hashval_t (TYPE_UNSIGNED (type), v); + hstate.add_int (TYPE_VECTOR_SUBPARTS (type)); + hstate.add_int (TYPE_UNSIGNED (type)); } if (TREE_CODE (type) == COMPLEX_TYPE) - v = iterative_hash_hashval_t (TYPE_UNSIGNED (type), v); + hstate.add_int (TYPE_UNSIGNED (type)); /* For pointer and reference types, fold in information about the type pointed to but do not recurse to the pointed-to type. */ if (POINTER_TYPE_P (type)) { - v = iterative_hash_hashval_t (TYPE_ADDR_SPACE (TREE_TYPE (type)), v); - v = iterative_hash_hashval_t (TREE_CODE (TREE_TYPE (type)), v); + hstate.add_int (TYPE_ADDR_SPACE (TREE_TYPE (type))); + hstate.add_int (TREE_CODE (TREE_TYPE (type))); } /* For integer types hash only the string flag. */ if (TREE_CODE (type) == INTEGER_TYPE) - v = iterative_hash_hashval_t (TYPE_STRING_FLAG (type), v); + hstate.add_int (TYPE_STRING_FLAG (type)); /* For array types hash the domain bounds and the string flag. */ if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type)) { - v = iterative_hash_hashval_t (TYPE_STRING_FLAG (type), v); + hstate.add_int (TYPE_STRING_FLAG (type)); /* OMP lowering can introduce error_mark_node in place of random local decls in types. */ if (TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != error_mark_node) - v = iterative_hash_expr (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), v); + hstate.add_int (iterative_hash_expr (TYPE_MIN_VALUE ( + TYPE_DOMAIN (type)), 0)); if (TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != error_mark_node) - v = iterative_hash_expr (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), v); + hstate.add_int (iterative_hash_expr (TYPE_MAX_VALUE ( + TYPE_DOMAIN (type)), 0)); } /* Recurse for aggregates with a single element type. */ if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == COMPLEX_TYPE || TREE_CODE (type) == VECTOR_TYPE) - v = iterative_hash_canonical_type (TREE_TYPE (type), v); + iterative_hash_canonical_type (TREE_TYPE (type), hstate); /* Incorporate function return and argument types. */ if (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE) @@ -346,17 +350,17 @@ hash_canonical_type (tree type) /* For method types also incorporate their parent class. */ if (TREE_CODE (type) == METHOD_TYPE) - v = iterative_hash_canonical_type (TYPE_METHOD_BASETYPE (type), v); + iterative_hash_canonical_type (TYPE_METHOD_BASETYPE (type), hstate); - v = iterative_hash_canonical_type (TREE_TYPE (type), v); + iterative_hash_canonical_type (TREE_TYPE (type), hstate); for (p = TYPE_ARG_TYPES (type), na = 0; p; p = TREE_CHAIN (p)) { - v = iterative_hash_canonical_type (TREE_VALUE (p), v); + iterative_hash_canonical_type (TREE_VALUE (p), hstate); na++; } - v = iterative_hash_hashval_t (na, v); + hstate.add_int (na); } if (RECORD_OR_UNION_TYPE_P (type)) @@ -367,20 +371,20 @@ hash_canonical_type (tree type) for (f = TYPE_FIELDS (type), nf = 0; f; f = TREE_CHAIN (f)) if (TREE_CODE (f) == FIELD_DECL) { - v = iterative_hash_canonical_type (TREE_TYPE (f), v); + iterative_hash_canonical_type (TREE_TYPE (f), hstate); nf++; } - v = iterative_hash_hashval_t (nf, v); + hstate.add_int (nf); } - return v; + return hstate.end(); } /* Returning a hash value for gimple type TYPE combined with VAL. */ -static hashval_t -iterative_hash_canonical_type (tree type, hashval_t val) +static void +iterative_hash_canonical_type (tree type, inchash &hstate) { hashval_t v; /* An already processed type. */ @@ -398,7 +402,7 @@ iterative_hash_canonical_type (tree type, hashval_t val) v = hash_canonical_type (type); gimple_register_canonical_type_1 (type, v); } - return iterative_hash_hashval_t (v, val); + hstate.add_int (v); } /* Returns the hash for a canonical type P. */