From patchwork Fri Oct 28 21:07:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 122495 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 39E7D1007D4 for ; Sat, 29 Oct 2011 08:07:55 +1100 (EST) Received: (qmail 21217 invoked by alias); 28 Oct 2011 21:07:52 -0000 Received: (qmail 21165 invoked by uid 22791); 28 Oct 2011 21:07:50 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, 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, 28 Oct 2011 21:07:29 +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.14.4/8.14.4) with ESMTP id p9SL7S5D015413 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 28 Oct 2011 17:07:28 -0400 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9SL7QBi021960 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 28 Oct 2011 17:07:28 -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 p9SL7NKD017236 for ; Fri, 28 Oct 2011 19:07:24 -0200 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 p9SL7Mh7019961; Fri, 28 Oct 2011 19:07:22 -0200 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id p9SL7JHt019959; Fri, 28 Oct 2011 19:07:19 -0200 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: [PR50869] don't attempt to expand CFA within cselib Date: Fri, 28 Oct 2011 19:07:18 -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 An assertion check meant to verify that var loc expansions that didn't involve VALUEs (say constants, REGs, etc) didn't push values onto the dependency stack failed in an expansion of the argp reg, because equivalences for it are preserved at cselib table resets, and cselib later tries to expand it to equivalent expressions. It's not profitable to expand it within var-tracking, and that's the only user of the CFA-base special-casing in cselib, so I arranged for argp to be preserved in expansions, just like other stack base registers. While debugging it, I noticed it was theoretically possible for the expression depth to remain uninitialized, and added an initialization and an assertion check to make sure it only remains zero when no location is found. Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install? for gcc/ChangeLog from Alexandre Oliva PR debug/50869 * cselib.c (cfa_base_preserved_regno): Initialize. (cselib_expand_value_rtx_1): Don't expand it. * var-tracking.c (vt_expand_var_loc_chain): Initialize depth. Check it's only zero if result is NULL. Index: gcc/cselib.c =================================================================== --- gcc/cselib.c.orig 2011-10-27 18:32:20.137366314 -0200 +++ gcc/cselib.c 2011-10-27 18:27:05.387597000 -0200 @@ -185,7 +185,7 @@ static cselib_val dummy_val; that is constant through the whole function and should never be eliminated. */ static cselib_val *cfa_base_preserved_val; -static unsigned int cfa_base_preserved_regno; +static unsigned int cfa_base_preserved_regno = INVALID_REGNUM; /* Used to list all values that contain memory reference. May or may not contain the useless values - the list is compacted @@ -1451,7 +1451,7 @@ cselib_expand_value_rtx_1 (rtx orig, str if (GET_MODE (l->elt->val_rtx) == GET_MODE (orig)) { rtx result; - int regno = REGNO (orig); + unsigned regno = REGNO (orig); /* The only thing that we are not willing to do (this is requirement of dse and if others potential uses @@ -1471,7 +1471,8 @@ cselib_expand_value_rtx_1 (rtx orig, str make the frame assumptions. */ if (regno == STACK_POINTER_REGNUM || regno == FRAME_POINTER_REGNUM - || regno == HARD_FRAME_POINTER_REGNUM) + || regno == HARD_FRAME_POINTER_REGNUM + || regno == cfa_base_preserved_regno) return orig; bitmap_set_bit (evd->regs_active, regno); Index: gcc/var-tracking.c =================================================================== --- gcc/var-tracking.c.orig 2011-10-27 18:32:20.141366261 -0200 +++ gcc/var-tracking.c 2011-10-27 18:28:03.823813000 -0200 @@ -7764,7 +7764,7 @@ vt_expand_var_loc_chain (variable var, b bool pending_recursion; rtx loc_from = NULL; struct elt_loc_list *cloc = NULL; - int depth, saved_depth = elcd->depth; + int depth = 0, saved_depth = elcd->depth; /* Clear all backlinks pointing at this, so that we're not notified while we're active. */ @@ -7842,6 +7842,8 @@ vt_expand_var_loc_chain (variable var, b VAR_LOC_FROM (var) = loc_from; VAR_LOC_DEPTH (var) = depth; + gcc_checking_assert (!depth == !result); + elcd->depth = update_depth (saved_depth, depth); /* Indicate whether any of the dependencies are pending recursion