From patchwork Sun May 20 17:56:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 160278 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]) by ozlabs.org (Postfix) with SMTP id A95FFB6FA7 for ; Mon, 21 May 2012 03:59:57 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1338141598; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:User-Agent:MIME-Version: Content-Type:Message-Id:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=enrWhMjW3ICsSk0ujE2coBjbCkI=; b=rCLs22t2uWCjzqd UNxzbWxHKCRXceR6VT/nIS2Ih7TFcoQvFxn2G2o/N9LAYGbQtj+1KzE4N3G14FWe XJTx66zfcizIzleZzW+oKSvJKiIBlP2ESgzSpvckuL02CxJ12aTAHpry+XrBxJzc LQDALvpOlBkkIXIu+toKzd8cg4nc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Subject:Date:User-Agent:MIME-Version:Content-Type:Message-Id:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=e361TrMuD6Ke+Fl966aNQdXLi4S0g0Wxl2VYJSixa1mqckZ4PbgTV+RSrtQoUP x3LqxGjPnnYpk1HPVz+TFD2dPmsXBsJjche8yWJ0gF6kUllRlarzhQebq3K7drSR ftK4AgB1I4sUfWiASAaJ5Ofbzs/xXANHdHC4V2CtxwhSE=; Received: (qmail 14011 invoked by alias); 20 May 2012 17:59:48 -0000 Received: (qmail 13995 invoked by uid 22791); 20 May 2012 17:59:46 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 20 May 2012 17:59:24 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 362FB29002D for ; Sun, 20 May 2012 19:59:29 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J0ix0MZ8Yflp for ; Sun, 20 May 2012 19:59:29 +0200 (CEST) Received: from [192.168.1.2] (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id F18F029000C for ; Sun, 20 May 2012 19:59:28 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix array type merging in LTO mode Date: Sun, 20 May 2012 19:56:50 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201205201956.50154.ebotcazou@adacore.com> 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 Hi, since http://gcc.gnu.org/ml/gcc-patches/2011-05/msg00833.html, canonical type merging for arrays takes hours instead of minutes for big Ada applications. The problem is that iterative_hash_canonical_type doesn't hash TYPE_MIN_VALUE and TYPE_MAX_VALUE for integer types anymore, so TYPE_DOMAIN is effectively not hashed anymore and the number of collisions goes to the roof in Ada. Fixed by the attached patch, which also removes a bogus comparison of the TYPE_SIZE of TYPE_DOMAIN in gimple_[canonical]types_compatible_p. LTO bootstrapped on x86_64-suse-linux, OK for mainline and 4.7 branch? 2012-05-20 Eric Botcazou * gimple.c (gimple_types_compatible_p_1) : Remove bogus size handling. (gimple_canonical_types_compatible_p) : Likewise. (iterative_hash_gimple_type): Adjust comment. (iterative_hash_canonical_type): Likewise. Hash the bounds of the domain for an array type. Index: gimple.c =================================================================== --- gimple.c (revision 187680) +++ gimple.c (working copy) @@ -3445,13 +3445,6 @@ gimple_types_compatible_p_1 (tree t1, tr goto same_types; else if (i1 == NULL_TREE || i2 == NULL_TREE) goto different_types; - /* If for a complete array type the possibly gimplified sizes - are different the types are different. */ - else if (((TYPE_SIZE (i1) != NULL) ^ (TYPE_SIZE (i2) != NULL)) - || (TYPE_SIZE (i1) - && TYPE_SIZE (i2) - && !operand_equal_p (TYPE_SIZE (i1), TYPE_SIZE (i2), 0))) - goto different_types; else { tree min1 = TYPE_MIN_VALUE (i1); @@ -3962,9 +3955,8 @@ iterative_hash_gimple_type (tree type, h v = iterative_hash_hashval_t (TYPE_STRING_FLAG (type), v); } - /* For array types hash their domain and the string flag. */ - if (TREE_CODE (type) == ARRAY_TYPE - && TYPE_DOMAIN (type)) + /* For array types hash the domain and the string flag. */ + if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type)) { v = iterative_hash_hashval_t (TYPE_STRING_FLAG (type), v); v = visit (TYPE_DOMAIN (type), state, v, @@ -4191,16 +4183,21 @@ iterative_hash_canonical_type (tree type v = iterative_hash_hashval_t (TREE_CODE (TREE_TYPE (type)), v); } - /* For integer types hash the types min/max values and the string flag. */ + /* For integer types hash the sizetype flag and the string flag. */ if (TREE_CODE (type) == INTEGER_TYPE) v = iterative_hash_hashval_t (TYPE_STRING_FLAG (type), v); - /* For array types hash their domain and the string flag. */ - if (TREE_CODE (type) == ARRAY_TYPE - && TYPE_DOMAIN (type)) + /* For array types hash the domain and its bounds, and the string flag. */ + if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type)) { v = iterative_hash_hashval_t (TYPE_STRING_FLAG (type), v); v = iterative_hash_canonical_type (TYPE_DOMAIN (type), v); + /* 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); + if (TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != error_mark_node) + v = iterative_hash_expr (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), v); } /* Recurse for aggregates with a single element type. */ @@ -4468,13 +4465,6 @@ gimple_canonical_types_compatible_p (tre return true; else if (i1 == NULL_TREE || i2 == NULL_TREE) return false; - /* If for a complete array type the possibly gimplified sizes - are different the types are different. */ - else if (((TYPE_SIZE (i1) != NULL) ^ (TYPE_SIZE (i2) != NULL)) - || (TYPE_SIZE (i1) - && TYPE_SIZE (i2) - && !operand_equal_p (TYPE_SIZE (i1), TYPE_SIZE (i2), 0))) - return false; else { tree min1 = TYPE_MIN_VALUE (i1);