From patchwork Thu Jan 20 16:23:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 79720 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 3C7F6B70E3 for ; Fri, 21 Jan 2011 03:23:38 +1100 (EST) Received: (qmail 22617 invoked by alias); 20 Jan 2011 16:23:34 -0000 Received: (qmail 22579 invoked by uid 22791); 20 Jan 2011 16:23:32 -0000 X-SWARE-Spam-Status: No, hits=-6.4 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, 20 Jan 2011 16:23:26 +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.13.8/8.13.8) with ESMTP id p0KGNONM023107 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 20 Jan 2011 11:23:24 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0KGNNsm011669 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 20 Jan 2011 11:23:23 -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 p0KGNMgP004020 for ; Thu, 20 Jan 2011 17:23:22 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p0KGNMMV004008 for gcc-patches@gcc.gnu.org; Thu, 20 Jan 2011 17:23:22 +0100 Date: Thu, 20 Jan 2011 17:23:22 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid creating (mem (debug_implict_ptr)) (PR debug/47283) Message-ID: <20110120162322.GX2724@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline 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 Hi! MEMs for something that is not addressable just confuse the aliasing code (expectedly) and furthermore result in unnecessarily large location description (DW_OP_GNU_implicit_pointer followed by DW_OP_deref*). This patch in that case just uses the COMPONENT_REF/ARRAY_REF etc. handling code, which will expand it as a SUBREG or similar. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2011-01-20 Jakub Jelinek PR debug/47283 * cfgexpand.c (expand_debug_expr): Instead of generating (mem (debug_implicit_ptr)) for MEM_REFs use COMPONENT_REF etc. handling. * g++.dg/debug/pr47283.C: New test. Jakub --- gcc/cfgexpand.c.jj 2011-01-03 09:54:28.000000000 +0100 +++ gcc/cfgexpand.c 2011-01-20 09:59:09.000000000 +0100 @@ -2567,6 +2567,13 @@ expand_debug_expr (tree exp) if (TREE_CODE (exp) == MEM_REF) { + if (GET_CODE (op0) == DEBUG_IMPLICIT_PTR + || (GET_CODE (op0) == PLUS + && GET_CODE (XEXP (op0, 0)) == DEBUG_IMPLICIT_PTR)) + /* (mem (debug_implicit_ptr)) might confuse aliasing. + Instead just use get_inner_reference. */ + goto component_ref; + op1 = expand_debug_expr (TREE_OPERAND (exp, 1)); if (!op1 || !CONST_INT_P (op1)) return NULL; @@ -2605,6 +2612,7 @@ expand_debug_expr (tree exp) return op0; + component_ref: case ARRAY_REF: case ARRAY_RANGE_REF: case COMPONENT_REF: --- gcc/testsuite/g++.dg/debug/pr47283.C.jj 2011-01-20 10:11:09.000000000 +0100 +++ gcc/testsuite/g++.dg/debug/pr47283.C 2011-01-20 10:13:16.000000000 +0100 @@ -0,0 +1,58 @@ +// PR debug/47283 +// { dg-do compile } + +template inline const T & +f1 (const T &a, const T &b) +{ + if (a < b) + return b; + return a; +}; + +struct A +{ + A (int w, int h) { a1 = w; } + A f2 (const A &) const; + int a1, a2; +}; + +inline A +A::f2 (const A &x) const +{ + return A (f1 (a1, x.a1), f1 (a2, x.a2)); +}; + +struct B +{ + A f3 () const; + void f4 (const A &) { b2 = 5 + b1; } + int b1, b2; +}; + +struct C +{ +}; + +struct D +{ + virtual C f5 (const C &) const; +}; + +struct E +{ + C f6 () const; + int f7 () const; + virtual B f8 (const C &) const; + A f9 () const; + virtual void f10 (); + struct F { D *h; } *d; +}; + +void +E::f10 () +{ + const C c = d->h->f5 (f6 ()); + B b = f8 (c); + b.f4 (b.f3 ().f2 (f9 ())); + f7 (); +}