From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13725 invoked by alias); 16 Nov 2009 20:42:43 -0000 Received: (qmail 13713 invoked by uid 22791); 16 Nov 2009 20:42:41 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,SUBJECT_FUZZY_VPILL 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, 16 Nov 2009 20:41:49 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAGKfm6G029593 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 16 Nov 2009 15:41:48 -0500 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nAGKfkbl004507 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 Nov 2009 15:41:47 -0500 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.3/8.14.3) with ESMTP id nAGKfk1N016582; Mon, 16 Nov 2009 18:41:46 -0200 Received: from livre.localdomain (aoliva@localhost [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5) with ESMTP id nAGKfjb9017261; Mon, 16 Nov 2009 18:41:46 -0200 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id nAGKfibR017259; Mon, 16 Nov 2009 18:41:44 -0200 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> Date: Mon, 16 Nov 2009 20:48:00 -0000 In-Reply-To: <84fc9c000911080156iff6d687o26db10af3e9fba5d@mail.gmail.com> (Richard Guenther's message of "Sun, 8 Nov 2009 10:56:38 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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 X-SW-Source: 2009-11/txt/msg00810.txt.bz2 --=-=-= Content-length: 1505 On Nov 8, 2009, Richard Guenther wrote: > For the rest it would be better to re-organize the code as > else if (gimple_code (def_stmt) == PHI_NODE) > { > value = degenerate_phi_result (def_stmt); > if (value > && walk_tree (&value, find_released_ssa_name, NULL, NULL)) > value = NULL_TREE; > } > that looks simpler and it avoids walking PHI args uselessly. That doesn't work. We crash deep within degenerate_phi_result given expressions containing released SSA names. It's the same reason why we have to test for released SSA names before calling gimple_assign_rhs_to_tree: IIRC it has to do with testing whether the already-NULL type of the SSA name is a pointer type. Regardless, I reorganized the code so as to not have to test for PHI_NODEs as often. There were two unrelated code paths intermixed with tests every now and again. Now they're two separate code flows. > @@ -479,6 +508,13 @@ insert_debug_temps_for_defs (gimple_stmt > stmt = gsi_stmt (*gsi); > + if (gimple_code (stmt) == GIMPLE_PHI) > + { > + tree var = gimple_phi_result (stmt); > + insert_debug_temp_for_var_def (gsi, var); > + return; > + } > + > 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. Here's what I'm going to test now. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=vta-ssa-dom-prop-degenerate.patch Content-length: 2580 for gcc/ChangeLog from Alexandre Oliva * tree-ssa.c (find_released_ssa_name): Handle NULL wi. (insert_debug_temp_for_var_def): Handle degenerate PHI nodes. (insert_debug_temps_for_defs): Handle PHI nodes. Index: gcc/tree-ssa.c =================================================================== --- gcc/tree-ssa.c.orig 2009-11-16 18:24:07.000000000 -0200 +++ gcc/tree-ssa.c 2009-11-16 18:41:04.000000000 -0200 @@ -279,7 +279,7 @@ find_released_ssa_name (tree *tp, int *w { struct walk_stmt_info *wi = (struct walk_stmt_info *) data_; - if (wi->is_lhs) + if (wi && wi->is_lhs) return NULL_TREE; if (TREE_CODE (*tp) == SSA_NAME) @@ -346,7 +346,33 @@ insert_debug_temp_for_var_def (gimple_st /* If we didn't get an insertion point, and the stmt has already been removed, we won't be able to insert the debug bind stmt, so we'll have to drop debug information. */ - if (is_gimple_assign (def_stmt)) + if (gimple_code (def_stmt) == GIMPLE_PHI) + { + bool no_value = false; + struct walk_stmt_info wi; + size_t i; + + memset (&wi, 0, sizeof (wi)); + + for (i = 0; i < gimple_phi_num_args (def_stmt); i++) + { + tree *argp = gimple_phi_arg_def_ptr (def_stmt, i); + + if (!*argp + || walk_tree (argp, find_released_ssa_name, NULL, NULL)) + { + no_value = true; + break; + } + } + + if (!no_value) + /* ??? We could handle at least some non-generate PHI + nodes by inserting debug temps on every edge. It's + not clear how much this would improve debug info. */ + value = degenerate_phi_result (def_stmt); + } + else if (is_gimple_assign (def_stmt)) { bool no_value = false; @@ -408,6 +434,7 @@ insert_debug_temp_for_var_def (gimple_st at the expense of duplication of expressions. */ if (CONSTANT_CLASS_P (value) + || gimple_code (def_stmt) == GIMPLE_PHI || (usecount == 1 && (!gimple_assign_single_p (def_stmt) || is_gimple_min_invariant (value))) @@ -478,6 +505,16 @@ insert_debug_temps_for_defs (gimple_stmt stmt = gsi_stmt (*gsi); + /* By the time we get here, the DEF in the PHI node seems to have + already been disconnected as an operand, so the FOR_EACH below + has no effect. Handle it explicitly. */ + if (gimple_code (stmt) == GIMPLE_PHI) + { + tree var = gimple_phi_result (stmt); + insert_debug_temp_for_var_def (gsi, var); + return; + } + FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, op_iter, SSA_OP_DEF) { tree var = DEF_FROM_PTR (def_p); --=-=-= Content-length: 257 -- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist Red Hat Brazil Compiler Engineer --=-=-=--