From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55001 invoked by alias); 27 Nov 2017 12:32:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 54992 invoked by uid 89); 27 Nov 2017 12:32:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=tree.c, treec, UD:tree.c X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Nov 2017 12:32:02 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 753D7ACB2 for ; Mon, 27 Nov 2017 12:32:00 +0000 (UTC) Date: Mon, 27 Nov 2017 12:43:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Clear stale entries from int_hash_table Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2017-11/txt/msg02291.txt.bz2 When ggc_free()ing TYPE_MIN/MAX_VALUE in type_hash_canon we have to make sure to not leave stale entries in int_hash_table. The following fixes that and also makes two related changes - freeing a built INTEGER_CST with a existing entry and properly hashing and finding redundancies of integer types with max value that doesn't fit into 64bits (any __int128 type). Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2017-11-27 Richard Biener * tree.c (wide_int_to_tree): Free discarded INTEGER_CST. (type_hash_canon): Also clear int_cst_hash_table entry for TYPE_MIN/MAX_VALUE. (build_nonstandard_integer_type): Hash all TYPE_MAX_VALUEs. Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 255138) +++ gcc/tree.c (working copy) @@ -1576,6 +1576,8 @@ wide_int_to_tree (tree type, const wide_ t = nt; *slot = t; } + else + ggc_free (nt); } return t; @@ -6496,10 +6502,18 @@ type_hash_canon (unsigned int hashcode, { if (TYPE_MIN_VALUE (type) && TREE_TYPE (TYPE_MIN_VALUE (type)) == type) - ggc_free (TYPE_MIN_VALUE (type)); + { + /* Zero is always in TYPE_CACHED_VALUES. */ + if (! TYPE_UNSIGNED (type)) + int_cst_hash_table->remove_elt (TYPE_MIN_VALUE (type)); + ggc_free (TYPE_MIN_VALUE (type)); + } if (TYPE_MAX_VALUE (type) && TREE_TYPE (TYPE_MAX_VALUE (type)) == type) - ggc_free (TYPE_MAX_VALUE (type)); + { + int_cst_hash_table->remove_elt (TYPE_MAX_VALUE (type)); + ggc_free (TYPE_MAX_VALUE (type)); + } if (TYPE_CACHED_VALUES_P (type)) ggc_free (TYPE_CACHED_VALUES (type)); } @@ -7486,8 +7500,10 @@ build_nonstandard_integer_type (unsigned fixup_signed_type (itype); ret = itype; - if (tree_fits_uhwi_p (TYPE_MAX_VALUE (itype))) - ret = type_hash_canon (tree_to_uhwi (TYPE_MAX_VALUE (itype)), itype); + + inchash::hash hstate; + inchash::add_expr (TYPE_MAX_VALUE (itype), hstate); + ret = type_hash_canon (hstate.end (), itype); if (precision <= MAX_INT_CACHED_PREC) nonstandard_integer_type_cache[precision + unsignedp] = ret;