From patchwork Tue Jul 27 07:01:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 59980 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 745D7B6EF0 for ; Tue, 27 Jul 2010 16:59:09 +1000 (EST) Received: (qmail 8857 invoked by alias); 27 Jul 2010 06:59:07 -0000 Received: (qmail 8848 invoked by uid 22791); 27 Jul 2010 06:59:07 -0000 X-SWARE-Spam-Status: No, hits=-6.1 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; Tue, 27 Jul 2010 06:59:02 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6R6x1sq031897 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 27 Jul 2010 02:59:01 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6R6x0Nq015547 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 27 Jul 2010 02:59:00 -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 o6R71NIC003994 for ; Tue, 27 Jul 2010 09:01:23 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o6R71M9d003993 for gcc-patches@gcc.gnu.org; Tue, 27 Jul 2010 09:01:22 +0200 Date: Tue, 27 Jul 2010 09:01:22 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Copy/update DECL_DEBUG_EXPR during inlining (PR tree-optimization/45083) Message-ID: <20100727070122.GS18378@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! We don't currently copy/update DECL_DEBUG_EXPR during inlining, the DECL_DEBUG_EXPR_IS_FROM bit is copied over to the new decls, but nothing sets DECL_DEBUG_EXPR. So, when early SRA creates some artificial vars after inlining that 1) we print the artificial variable names in diagnostics instead of the source expressions 2) accurate debug info for those SRA optimized variables that were inlined can't be produced. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux. Ok for trunk? 2010-07-27 Jakub Jelinek PR tree-optimization/45083 * tree-inline.c (add_local_variables): Also remap DECL_DEBUG_EXPR. * gcc.dg/pr45083.c: New test. Jakub --- gcc/tree-inline.c.jj 2010-07-22 11:35:37.000000000 +0200 +++ gcc/tree-inline.c 2010-07-26 21:08:11.000000000 +0200 @@ -3687,7 +3687,24 @@ add_local_variables (struct function *ca add_local_decl (caller, var); } else if (!can_be_nonlocal (var, id)) - add_local_decl (caller, remap_decl (var, id)); + { + tree new_var = remap_decl (var, id); + + /* Remap debug-expressions. */ + if (TREE_CODE (new_var) == VAR_DECL + && DECL_DEBUG_EXPR_IS_FROM (new_var) + && new_var != var) + { + tree tem = DECL_DEBUG_EXPR (var); + bool old_regimplify = id->regimplify; + id->remapping_type_depth++; + walk_tree (&tem, copy_tree_body_r, id, NULL); + id->remapping_type_depth--; + id->regimplify = old_regimplify; + SET_DECL_DEBUG_EXPR (new_var, tem); + } + add_local_decl (caller, new_var); + } } /* Fetch callee declaration from the call graph edge going from NODE and --- gcc/testsuite/gcc.dg/pr45083.c.jj 2010-07-26 21:10:36.000000000 +0200 +++ gcc/testsuite/gcc.dg/pr45083.c 2010-07-26 21:13:52.000000000 +0200 @@ -0,0 +1,25 @@ +/* PR tree-optimization/45083 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +struct S { char *a; unsigned b; unsigned c; }; +extern int foo (const char *); +extern void bar (int, int); + +static void +baz (void) +{ + struct S cs[1]; /* { dg-message "was declared here" } */ + switch (cs->b) /* { dg-warning "cs\[^\n\r\]*\\.b\[^\n\r\]*is used uninitialized" } */ + { + case 101: + if (foo (cs->a)) /* { dg-warning "cs\[^\n\r\]*\\.a\[^\n\r\]*may be used uninitialized" } */ + bar (cs->c, cs->b); /* { dg-warning "cs\[^\n\r\]*\\.c\[^\n\r\]*may be used uninitialized" } */ + } +} + +void +test (void) +{ + baz (); +}