From patchwork Thu Nov 11 15:28:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 70823 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 62033B7144 for ; Fri, 12 Nov 2010 02:29:15 +1100 (EST) Received: (qmail 28371 invoked by alias); 11 Nov 2010 15:29:09 -0000 Received: (qmail 28360 invoked by uid 22791); 11 Nov 2010 15:29:07 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD 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; Thu, 11 Nov 2010 15:28:54 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oABFSrim006706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 11 Nov 2010 10:28:53 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oABFSqMG014399 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 11 Nov 2010 10:28:52 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id oABFSp6D025961; Thu, 11 Nov 2010 16:28:51 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id oABFSpns025959; Thu, 11 Nov 2010 16:28:51 +0100 Date: Thu, 11 Nov 2010 16:28:51 +0100 From: Jakub Jelinek To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix var-tracking ICE (PR debug/46387) Message-ID: <20101111152851.GE29412@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20101110231619.GY29412@tyan-ft48-01.lab.bos.redhat.com> <20101111101824.GD29412@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 Thu, Nov 11, 2010 at 11:45:50AM +0100, Richard Guenther wrote: > I see. I'm not sure I like the special just-for-vartracking function in alias.c > too much (in fact I hoped we can share it for selsched). Ok, here is a simpler version where it can't be reverted (except for init_alias_analysis) and var-tracking doesn't try to revert it. Bootstrapped/regtested on x86_64-linux and i686-linux, tested on the testcase with ia64-linux cross, ok for trunk? 2010-11-11 Jakub Jelinek PR debug/46387 * rtl.h (equate_reg_base_value): New prototype. * alias.c (equate_reg_base_value): New function. * var-tracking.c (vt_init_cfa_base): Use it. * gcc.dg/pr46387.c: New test. Jakub --- gcc/rtl.h.jj 2010-11-10 13:14:41.000000000 +0100 +++ gcc/rtl.h 2010-11-11 12:52:52.000000000 +0100 @@ -2503,6 +2503,7 @@ extern int may_alias_p (const_rtx, const extern void init_alias_target (void); extern void init_alias_analysis (void); extern void end_alias_analysis (void); +extern void equate_reg_base_value (const_rtx, const_rtx); extern bool memory_modified_in_insn_p (const_rtx, const_rtx); extern rtx find_base_term (rtx); extern rtx gen_hard_reg_clobber (enum machine_mode, unsigned int); --- gcc/alias.c.jj 2010-11-10 13:14:41.000000000 +0100 +++ gcc/alias.c 2010-11-11 12:54:01.000000000 +0100 @@ -2906,6 +2906,14 @@ init_alias_analysis (void) timevar_pop (TV_ALIAS_ANALYSIS); } +/* Equate REG_BASE_VALUE (reg1) to REG_BASE_VALUE (reg2). */ + +void +equate_reg_base_value (const_rtx reg1, const_rtx reg2) +{ + VEC_replace (rtx, reg_base_value, REGNO (reg1), REG_BASE_VALUE (reg2)); +} + void end_alias_analysis (void) { --- gcc/var-tracking.c.jj 2010-11-10 13:14:41.000000000 +0100 +++ gcc/var-tracking.c 2010-11-11 12:53:27.000000000 +0100 @@ -8229,6 +8229,11 @@ vt_init_cfa_base (void) if (!MAY_HAVE_DEBUG_INSNS) return; + /* Tell alias analysis that cfa_base_rtx should share + find_base_term value with stack pointer or hard frame pointer. */ + equate_reg_base_value (cfa_base_rtx, + frame_pointer_needed + ? hard_frame_pointer_rtx : stack_pointer_rtx); val = cselib_lookup_from_insn (cfa_base_rtx, GET_MODE (cfa_base_rtx), 1, get_insns ()); preserve_value (val); --- gcc/testsuite/gcc.dg/pr46387.c.jj 2010-11-11 12:52:52.000000000 +0100 +++ gcc/testsuite/gcc.dg/pr46387.c 2010-11-11 12:52:52.000000000 +0100 @@ -0,0 +1,32 @@ +/* PR debug/46387 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ + +struct S { double x; double y; short z; }; +int a = 0, b = 0, c; +void bar (int, int, int); +void baz (int *, int *, int *); + +void +foo (struct S *v) +{ + int x, y, z; + if (!a && b != 0) + return; + if (v->z) + baz (&x, &y, &z); + else + { + x = v->x; + y = v->y; + } + x = x / (5 + 1); + y = y / (5 + 1); + if (x < 0) + x = 0; + if (x > c - 1) + x = c - 1; + if (b == 0) + bar (x, y, 1); + return; +}