From patchwork Wed May 25 10:29:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 97323 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 09E14B6F9B for ; Wed, 25 May 2011 20:29:21 +1000 (EST) Received: (qmail 19956 invoked by alias); 25 May 2011 10:29:20 -0000 Received: (qmail 19947 invoked by uid 22791); 25 May 2011 10:29:19 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 May 2011 10:29:03 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 3C41C94033 for ; Wed, 25 May 2011 12:29:02 +0200 (CEST) Date: Wed, 25 May 2011 12:29:02 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Ignore TYPE_DECLs for canonical type compute in LTO Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 Just figured that we'd get TYPE_DECLs and FUNCTION_DECLs in aggregate types. But we should treat layout-compatible structs as same, regardless of the above. LTO profile-bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2011-05-25 Richard Guenther * gimple.c (iterative_hash_canonical_type): Skip non-FIELD_DECLs. (gimple_canonical_types_compatible_p): Likewise. Index: gcc/gimple.c =================================================================== --- gcc/gimple.c (revision 174118) +++ gcc/gimple.c (working copy) @@ -4376,10 +4382,11 @@ iterative_hash_canonical_type (tree type tree f; for (f = TYPE_FIELDS (type), nf = 0; f; f = TREE_CHAIN (f)) - { - v = iterative_hash_canonical_type (TREE_TYPE (f), v); - nf++; - } + if (TREE_CODE (f) == FIELD_DECL) + { + v = iterative_hash_canonical_type (TREE_TYPE (f), v); + nf++; + } v = iterative_hash_hashval_t (nf, v); } @@ -4688,6 +4695,13 @@ gimple_canonical_types_compatible_p (tre f1 && f2; f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2)) { + /* Skip non-fields. */ + while (f1 && TREE_CODE (f1) != FIELD_DECL) + f1 = TREE_CHAIN (f1); + while (f2 && TREE_CODE (f2) != FIELD_DECL) + f2 = TREE_CHAIN (f2); + if (!f1 || !f2) + break; /* The fields must have the same name, offset and type. */ if (DECL_NONADDRESSABLE_P (f1) != DECL_NONADDRESSABLE_P (f2) || !gimple_compare_field_offset (f1, f2)