From patchwork Fri Jun 3 14:33:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 98591 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 C151BB6FAA for ; Sat, 4 Jun 2011 00:38:41 +1000 (EST) Received: (qmail 8995 invoked by alias); 3 Jun 2011 14:38:39 -0000 Received: (qmail 8985 invoked by uid 22791); 3 Jun 2011 14:38:38 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, 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; Fri, 03 Jun 2011 14:38:23 +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.14.4/8.14.4) with ESMTP id p53EcN0V027188 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 3 Jun 2011 10:38:23 -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 p53EcAfS009990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 3 Jun 2011 10:38:16 -0400 Received: from livre.localdomain (livre-to-gw.oliva.athome.lsd.ic.unicamp.br [172.31.160.19]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.4/8.14.4) with ESMTP id p53Ec3W5022037; Fri, 3 Jun 2011 11:38:08 -0300 Received: from livre.localdomain (aoliva@localhost.localdomain [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p53EXwT3021271; Fri, 3 Jun 2011 11:34:03 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id p53EXtaM021269; Fri, 3 Jun 2011 11:33:55 -0300 From: Alexandre Oliva To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Subject: Re: [vta, graphite?] propagate degenerate phi nodes into debug stmts References: <84fc9c000911080156iff6d687o26db10af3e9fba5d@mail.gmail.com> <84fc9c000911170739v76a2e911vc6794e597c8d134e@mail.gmail.com> <84fc9c000911190253v19390bd2le683c769bf0ab4d@mail.gmail.com> Date: Fri, 03 Jun 2011 11:33:55 -0300 In-Reply-To: <84fc9c000911190253v19390bd2le683c769bf0ab4d@mail.gmail.com> (Richard Guenther's message of "Thu, 19 Nov 2009 11:53:24 +0100") 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 According to http://gcc.gnu.org/ml/gcc-patches/2009-11/msg00999.html on Nov 19, 2009, Richard Guenther wrote: > On Thu, Nov 19, 2009 at 4:05 AM, Alexandre Oliva wrote: >> On Nov 17, 2009, Richard Guenther wrote: >> >>>>> This looks odd.  SSA DEF operand iteration should walk the PHI defs >>>>> as well, so the change should not be necessary. >> >>>> I thought so, too, but by the time we get there, the operands of the PHI >>>> stmt have already been disconnected. >> >>> It shouldn't be.  Please try to figure out why instead. >> >> Gotta use a different FOR_EACH macro to handle PHI nodes. >> >> s/FOR_EACH_SSA_DEF_OPERAND/FOR_EACH_PHI_OR_STMT_DEF/ fixed it. >> >> In order to make sure no other such mistakes had been made in GCC, I >> added an assertion check in the iterator initializer and adjusted the >> uses of GIMPLE_PHI nodes that triggered the assertion, but that would >> have done nothing whatsoever in its absence.  I haven't looked into >> whether doing nothing is correct. >> >> Should I check this in? > I think we should rather let num_ssa_operands and delink_stmt_imm_use > ICE on PHIs, but I'd rather do this in stage1 - can you queue this > patch until then? You meant 4.6 stage1, but I missed it. How's it for 4.7 stage1? Regstrapped on x86_64-linux-gnu and i686-linux-gnu. for gcc/ChangeLog from Alexandre Oliva * tree-flow-inline.h (op_iter_init): Reject GIMPLE_PHI stmts. (num_ssa_operands): Skip GIMPLE_PHI. (delink_stmt_imm_use): Likewise. Index: gcc/tree-flow-inline.h =================================================================== --- gcc/tree-flow-inline.h.orig 2010-06-10 07:20:02.000000000 -0300 +++ gcc/tree-flow-inline.h 2010-06-10 15:17:51.000000000 -0300 @@ -716,9 +716,11 @@ clear_and_done_ssa_iter (ssa_op_iter *pt static inline void op_iter_init (ssa_op_iter *ptr, gimple stmt, int flags) { - /* We do not support iterating over virtual defs or uses without + /* PHI nodes require a different iterator initialization path. We + do not support iterating over virtual defs or uses without iterating over defs or uses at the same time. */ - gcc_checking_assert ((!(flags & SSA_OP_VDEF) || (flags & SSA_OP_DEF)) + gcc_checking_assert (gimple_code (stmt) != GIMPLE_PHI + && (!(flags & SSA_OP_VDEF) || (flags & SSA_OP_DEF)) && (!(flags & SSA_OP_VUSE) || (flags & SSA_OP_USE))); ptr->defs = (flags & (SSA_OP_DEF|SSA_OP_VDEF)) ? gimple_def_ops (stmt) : NULL; if (!(flags & SSA_OP_VDEF) @@ -847,8 +849,9 @@ num_ssa_operands (gimple stmt, int flags tree t; int num = 0; - FOR_EACH_SSA_TREE_OPERAND (t, stmt, iter, flags) - num++; + if (gimple_code (stmt) != GIMPLE_PHI) + FOR_EACH_SSA_TREE_OPERAND (t, stmt, iter, flags) + num++; return num; } @@ -860,7 +863,8 @@ delink_stmt_imm_use (gimple stmt) ssa_op_iter iter; use_operand_p use_p; - if (ssa_operands_active ()) + if (ssa_operands_active () + && gimple_code (stmt) != GIMPLE_PHI) FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES) delink_imm_use (use_p); }