From patchwork Mon Jul 5 19:32:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 57925 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 00B64B6EED for ; Tue, 6 Jul 2010 05:31:22 +1000 (EST) Received: (qmail 26714 invoked by alias); 5 Jul 2010 19:31:13 -0000 Received: (qmail 26702 invoked by uid 22791); 5 Jul 2010 19:31:12 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_NR, 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; Mon, 05 Jul 2010 19:31:04 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o65JV24U025701 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Jul 2010 15:31:02 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o65JV1Fu001462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 5 Jul 2010 15:31:02 -0400 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 o65JWGwh020194; Mon, 5 Jul 2010 21:32:16 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o65JWFfb020193; Mon, 5 Jul 2010 21:32:15 +0200 Date: Mon, 5 Jul 2010 21:32:15 +0200 From: Jakub Jelinek To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix debuginfo after tree_nrv Message-ID: <20100705193215.GD28610@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) 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! As noted by Honza, tree_nrv doesn't play very well with debuginfo (the optimized away variable has no location). This patch fixes it, bootstrapped/regtested on x86_64-linux and i686-linux. Ok for trunk? 2010-07-05 Jakub Jelinek * tree-nrv.c (tree_nrv): Set DECL_VALUE_EXPR on found to result. * gcc.dg/guality/nrv-1.c: New test. Jakub --- gcc/tree-nrv.c.jj 2010-06-07 11:25:05.000000000 +0200 +++ gcc/tree-nrv.c 2010-07-05 18:37:44.000000000 +0200 @@ -259,6 +259,9 @@ tree_nrv (void) } } + SET_DECL_VALUE_EXPR (found, result); + DECL_HAS_VALUE_EXPR_P (found) = 1; + /* FOUND is no longer used. Ensure it gets removed. */ var_ann (found)->used = 0; return 0; --- gcc/testsuite/gcc.dg/guality/nrv-1.c.jj 2010-07-05 18:29:31.000000000 +0200 +++ gcc/testsuite/gcc.dg/guality/nrv-1.c 2010-07-05 18:36:48.000000000 +0200 @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "-g -fno-tree-sra" } */ + +void abort (void); + +struct A +{ + int i[100]; +}; + +struct A a1, a3; + +__attribute__((noinline)) struct A +f () +{ + struct A a2; + a2.i[0] = 42; + if (a3.i[0] != 0) + abort (); + a2.i[4] = 7; /* { dg-final { gdb-test 20 "a2.i\[0\]" "42" } } */ + return a2; +} + +int +main () +{ + a1 = f (); + return 0; +}