From patchwork Mon Sep 6 17:57:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 63951 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 D8B9BB70FC for ; Tue, 7 Sep 2010 03:57:47 +1000 (EST) Received: (qmail 4274 invoked by alias); 6 Sep 2010 17:57:46 -0000 Received: (qmail 4266 invoked by uid 22791); 6 Sep 2010 17:57:45 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Sep 2010 17:57:38 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o86Hva6C012778 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 6 Sep 2010 13:57:36 -0400 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o86HvZsd001328 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 6 Sep 2010 13:57:36 -0400 Received: from livre.localdomain (livre.oliva.athome.lsd.ic.unicamp.br [172.31.160.2]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.4/8.14.4) with ESMTP id o86HvYoc017163; Mon, 6 Sep 2010 14:57:34 -0300 Received: from livre.localdomain (aoliva@localhost [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o86HvXlU026287; Mon, 6 Sep 2010 14:57:33 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id o86HvXIq026285; Mon, 6 Sep 2010 14:57:33 -0300 From: Alexandre Oliva To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Subject: Re: [PR debug/45130] fix MEM_REF -fcompare-debug regression References: Date: Mon, 06 Sep 2010 14:57:32 -0300 In-Reply-To: (Richard Guenther's message of "Sun, 5 Sep 2010 10:49:42 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) 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 On Sep 5, 2010, Richard Guenther wrote: > + If OEP_SAME_TYPE is set, then mismatched types */ > there seems to be missing sth. Ugh. Sorry. > Thus, simply add a type equality check for operand 1 in operand_equal_p here: Thanks. I'm going ahead and hashing the main type variant of operand 1, and discarding qualifiers and checking types when dumping trees. How does this look? (pending regstrap) for gcc/ChangeLog from Alexandre Oliva PR debug/45419 PR debug/45408 * tree-pretty-print.c (dump_generic_node): Disregard top-level qualifiers in otherwise equal MEM_REF pointer types. * fold-const.c (operand_equal_p): Compare pointer type of MEM_REFs. * tree.c (iterative_hash_expr): Hash the pointer type of MEM_REFs. Index: gcc/tree-pretty-print.c =================================================================== --- gcc/tree-pretty-print.c.orig 2010-09-05 09:17:52.542299276 -0300 +++ gcc/tree-pretty-print.c 2010-09-06 14:50:07.000000000 -0300 @@ -807,8 +807,8 @@ dump_generic_node (pretty_printer *buffe == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1)))) && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0))) == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1)))) - && (TYPE_QUALS (TREE_TYPE (TREE_OPERAND (node, 0))) - == TYPE_QUALS (TREE_TYPE (TREE_OPERAND (node, 1)))) + && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 0))) + == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)))) /* Same value types ignoring qualifiers. */ && (TYPE_MAIN_VARIANT (TREE_TYPE (node)) == TYPE_MAIN_VARIANT @@ -827,9 +827,12 @@ dump_generic_node (pretty_printer *buffe } else { + tree ptype; + pp_string (buffer, "MEM["); pp_string (buffer, "("); - dump_generic_node (buffer, TREE_TYPE (TREE_OPERAND (node, 1)), + ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1))); + dump_generic_node (buffer, ptype, spc, flags | TDF_SLIM, false); pp_string (buffer, ")"); dump_generic_node (buffer, TREE_OPERAND (node, 0), Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c.orig 2010-09-05 09:17:52.620425283 -0300 +++ gcc/fold-const.c 2010-09-06 14:32:03.000000000 -0300 @@ -2593,14 +2593,17 @@ operand_equal_p (const_tree arg0, const_ return OP_SAME (0); case MEM_REF: - /* Require equal access sizes. We can have incomplete types - for array references of variable-sized arrays from the - Fortran frontent though. */ + /* Require equal access sizes, and similar pointer types. + We can have incomplete types for array references of + variable-sized arrays from the Fortran frontent + though. */ return ((TYPE_SIZE (TREE_TYPE (arg0)) == TYPE_SIZE (TREE_TYPE (arg1)) || (TYPE_SIZE (TREE_TYPE (arg0)) && TYPE_SIZE (TREE_TYPE (arg1)) && operand_equal_p (TYPE_SIZE (TREE_TYPE (arg0)), TYPE_SIZE (TREE_TYPE (arg1)), flags))) + && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg0, 1))) + == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg1, 1)))) && OP_SAME (0) && OP_SAME (1)); case ARRAY_REF: Index: gcc/tree.c =================================================================== --- gcc/tree.c.orig 2010-09-05 09:17:52.677304476 -0300 +++ gcc/tree.c 2010-09-06 14:46:57.000000000 -0300 @@ -6734,6 +6734,21 @@ iterative_hash_expr (const_tree t, hashv } return val; } + case MEM_REF: + { + tree type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (t, 1))); + + /* The type of the second operand is irrelevant, except for + its top-level qualifiers. */ + val = iterative_hash_object (TYPE_HASH (type), val); + + /* We could use the standard hash computation from this point + on. */ + val = iterative_hash_object (code, val); + val = iterative_hash_expr (TREE_OPERAND (t, 1), val); + val = iterative_hash_expr (TREE_OPERAND (t, 0), val); + return val; + } case FUNCTION_DECL: /* When referring to a built-in FUNCTION_DECL, use the __builtin__ form. Otherwise nodes that compare equal according to operand_equal_p might