From patchwork Fri Dec 2 19:28:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 128945 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 719CA1007D4 for ; Sat, 3 Dec 2011 06:29:10 +1100 (EST) Received: (qmail 1049 invoked by alias); 2 Dec 2011 19:29:08 -0000 Received: (qmail 1041 invoked by uid 22791); 2 Dec 2011 19:29:07 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_TM 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, 02 Dec 2011 19:28:50 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pB2JSoeM006524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 2 Dec 2011 14:28:50 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pB2JSnGK031992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 2 Dec 2011 14:28:49 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id pB2JSmTa016679; Fri, 2 Dec 2011 20:28:48 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id pB2JSmnn016678; Fri, 2 Dec 2011 20:28:48 +0100 Date: Fri, 2 Dec 2011 20:28:48 +0100 From: Jakub Jelinek To: Richard Guenther Cc: Alexandre Oliva , Michael Matz , gcc-patches@gcc.gnu.org Subject: [PATCH] Improve debug info if tree DCE removes stores (PR debug/50317, fallout) Message-ID: <20111202192848.GH27242@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20111201164906.GZ27242@tyan-ft48-01.lab.bos.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Fri, Dec 02, 2011 at 02:27:40PM +0100, Richard Guenther wrote: > This change seems wrong. We are turning valid gimple > > # DEBUG D#2 => transfer.0 [with addres taken] > > into invalid one > > # DEBUG D#2 => transfer.0 [without address taken] > > once you update that stmt with update_stmt you'll get an SSA operand > for transfer.0 which is not in SSA form because you fail to rewrite it > into. > > Why do this in remove_unused_locals and not in update_address_taken? > Or, why do it at all? > > I have a SSA operand checking patch that catches this now ... Here is a fix for that. Instead of clearing TREE_ADDRESSABLE for unreferenced vars we allow them in target_for_debug_bind if they aren't referenced vars (thus we don't risk mixing VALUE tracking with the old style REG_EXPR/MEM_EXPR tracking of these variables). Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2011-12-02 Jakub Jelinek PR debug/50317 * tree-ssa.c (target_for_debug_bind): Also allow is_gimple_reg_type vars that aren't referenced. (tree-ssa-live.c (remove_unused_locals): Don't clear TREE_ADDRESSABLE of unreferenced local vars. * cfgexpand.c (expand_debug_expr): For DEBUG_IMPLICIT_PTR allow also TREE_ADDRESSABLE vars that satisfy target_for_debug_bind. Jakub --- gcc/tree-ssa.c.jj 2011-11-29 08:58:52.000000000 +0100 +++ gcc/tree-ssa.c 2011-12-02 15:04:03.494148642 +0100 @@ -264,7 +264,12 @@ target_for_debug_bind (tree var) return NULL_TREE; if (!is_gimple_reg (var)) - return NULL_TREE; + { + if (is_gimple_reg_type (TREE_TYPE (var)) + && referenced_var_lookup (cfun, DECL_UID (var)) == NULL_TREE) + return var; + return NULL_TREE; + } return var; } --- gcc/tree-ssa-live.c.jj 2011-12-02 01:52:27.000000000 +0100 +++ gcc/tree-ssa-live.c 2011-12-02 15:04:59.601816335 +0100 @@ -814,15 +814,7 @@ remove_unused_locals (void) bitmap_set_bit (global_unused_vars, DECL_UID (var)); } else - { - /* For unreferenced local vars drop TREE_ADDRESSABLE - bit in case it is referenced from debug stmts. */ - if (DECL_CONTEXT (var) == current_function_decl - && TREE_ADDRESSABLE (var) - && is_gimple_reg_type (TREE_TYPE (var))) - TREE_ADDRESSABLE (var) = 0; - continue; - } + continue; } else if (TREE_CODE (var) == VAR_DECL && DECL_HARD_REGISTER (var) --- gcc/cfgexpand.c.jj 2011-12-02 01:52:27.000000000 +0100 +++ gcc/cfgexpand.c 2011-12-02 15:24:37.982327507 +0100 @@ -3325,7 +3325,8 @@ expand_debug_expr (tree exp) if ((TREE_CODE (TREE_OPERAND (exp, 0)) == VAR_DECL || TREE_CODE (TREE_OPERAND (exp, 0)) == PARM_DECL || TREE_CODE (TREE_OPERAND (exp, 0)) == RESULT_DECL) - && !TREE_ADDRESSABLE (TREE_OPERAND (exp, 0))) + && (!TREE_ADDRESSABLE (TREE_OPERAND (exp, 0)) + || target_for_debug_bind (TREE_OPERAND (exp, 0)))) return gen_rtx_DEBUG_IMPLICIT_PTR (mode, TREE_OPERAND (exp, 0)); if (handled_component_p (TREE_OPERAND (exp, 0))) @@ -3337,7 +3338,8 @@ expand_debug_expr (tree exp) if ((TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == RESULT_DECL) - && !TREE_ADDRESSABLE (decl) + && (!TREE_ADDRESSABLE (decl) + || target_for_debug_bind (decl)) && (bitoffset % BITS_PER_UNIT) == 0 && bitsize > 0 && bitsize == maxsize)