From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24232 invoked by alias); 19 Feb 2010 22:19:06 -0000 Received: (qmail 24216 invoked by uid 22791); 19 Feb 2010 22:19:01 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS 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, 19 Feb 2010 22:18:57 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1JMIuAU004461 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Feb 2010 17:18:56 -0500 Received: from [IPv6:::1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1JMIsfD015689; Fri, 19 Feb 2010 17:18:55 -0500 Message-ID: <4B7F0E4E.4090902@redhat.com> Date: Fri, 19 Feb 2010 22:19:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100218 Lightning/1.0b1 Shredder/3.0.3pre MIME-Version: 1.0 To: gcc-patches List CC: Jakub Jelinek Subject: RFA: PATCH to expand_used_vars for debug/42800 Content-Type: multipart/mixed; boundary="------------070507000800070907030003" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-02/txt/msg00802.txt.bz2 This is a multi-part message in MIME format. --------------070507000800070907030003 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 810 The problem is this PR is that when are writing out the debug info for the temporary containing the upper bound of the VLA, its rtl still refers to virtual regs, so dwarf2out gives up and doesn't emit any debug info for the upper bound. This happens because the Expand from SSA patch broke Jakub's patch for PR 34037, such that expand_used_vars is no longer re-adding the variable to cfun->local_decls. The patch adjusts the logic in expand_used_vars so that the PR 34037 fix is executed again for this variable. I have also attached a second (alternative) patch which fixes the symptom by calling instantiate_decl_rtl from dwarf2out. This patch is lower in impact, but I think the first patch is safe enough that we don't need to be this conservative. Tested x86_64-pc-linux-gnu. OK for trunk? --------------070507000800070907030003 Content-Type: text/x-patch; name="42800.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="42800.patch" Content-length: 3273 commit 7b71cfa84b5c7e3c169f25e057789b5053a2b640 Author: Jason Merrill Date: Fri Feb 19 14:40:57 2010 -0500 PR debug/42800 * cfgexpand.c (expand_used_vars): Keep artificial non-ignored vars in cfun->local_decls even if they have register types. diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 53beecd..ee26ee4 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -1331,8 +1331,7 @@ expand_used_vars (void) if (is_gimple_reg (var)) { TREE_USED (var) = 0; - ggc_free (t); - continue; + goto next; } /* We didn't set a block for static or extern because it's hard to tell the difference between a global variable (re)declared @@ -1353,20 +1352,20 @@ expand_used_vars (void) TREE_USED (var) = 1; if (expand_now) + expand_one_var (var, true, true); + + next: + if (DECL_ARTIFICIAL (var) && !DECL_IGNORED_P (var)) { - expand_one_var (var, true, true); - if (DECL_ARTIFICIAL (var) && !DECL_IGNORED_P (var)) - { - rtx rtl = DECL_RTL_IF_SET (var); + rtx rtl = DECL_RTL_IF_SET (var); - /* Keep artificial non-ignored vars in cfun->local_decls - chain until instantiate_decls. */ - if (rtl && (MEM_P (rtl) || GET_CODE (rtl) == CONCAT)) - { - TREE_CHAIN (t) = cfun->local_decls; - cfun->local_decls = t; - continue; - } + /* Keep artificial non-ignored vars in cfun->local_decls + chain until instantiate_decls. */ + if (rtl && (MEM_P (rtl) || GET_CODE (rtl) == CONCAT)) + { + TREE_CHAIN (t) = cfun->local_decls; + cfun->local_decls = t; + continue; } } diff --git a/gcc/testsuite/c-c++-common/dwarf2/vla1.c b/gcc/testsuite/c-c++-common/dwarf2/vla1.c new file mode 100644 index 0000000..e814bf5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dwarf2/vla1.c @@ -0,0 +1,11 @@ +// PR debug/42800 +// { dg-options "-gdwarf-2 -dA" } +// { dg-final { scan-assembler "DW_AT_upper_bound" } } + +int +f (int i) +{ + char a[i]; + + return a[0]; +} diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp index 1255d06..1a874f8 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp +++ b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp @@ -35,7 +35,7 @@ set comp_output [g++_target_compile \ if { ! [string match "*: target system does not support the * debug format*" \ $comp_output] } { remove-build-file "trivial.S" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[C\]]] \ + dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/dwarf2/*.c]] \ "" $DEFAULT_CFLAGS } diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp index 73c2c44..74136ae 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp @@ -35,7 +35,7 @@ set comp_output [gcc_target_compile \ if { ! [string match "*: target system does not support the * debug format*" \ $comp_output] } { remove-build-file "trivial.S" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \ + dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] $srcdir/c-c++-common/dwarf2/*.c]] \ "" $DEFAULT_CFLAGS } --------------070507000800070907030003 Content-Type: text/x-patch; name="42800-2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="42800-2.patch" Content-length: 2415 commit e0da647b68443f8c6b705aec72c5a6ffd26ae38a Author: Jason Merrill Date: Fri Feb 19 14:40:57 2010 -0500 PR debug/42800 * dwarf2out.c (rtl_for_decl_location): Call instantiate_decl_rtl. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 2e8712f..0de7152 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -15750,6 +15750,11 @@ rtl_for_decl_location (tree decl) if (rtl) rtl = avoid_constant_pool_reference (rtl); + /* Instantiate any virtual regs. FIXME should have happened in + instantiate_decls. */ + if (rtl) + instantiate_decl_rtl (rtl); + /* Try harder to get a rtl. If this symbol ends up not being emitted in the current CU, resolve_addr will remove the expression referencing it. */ diff --git a/gcc/testsuite/c-c++-common/dwarf2/vla1.c b/gcc/testsuite/c-c++-common/dwarf2/vla1.c new file mode 100644 index 0000000..e814bf5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dwarf2/vla1.c @@ -0,0 +1,11 @@ +// PR debug/42800 +// { dg-options "-gdwarf-2 -dA" } +// { dg-final { scan-assembler "DW_AT_upper_bound" } } + +int +f (int i) +{ + char a[i]; + + return a[0]; +} diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp index 1255d06..1a874f8 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp +++ b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp @@ -35,7 +35,7 @@ set comp_output [g++_target_compile \ if { ! [string match "*: target system does not support the * debug format*" \ $comp_output] } { remove-build-file "trivial.S" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[C\]]] \ + dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/dwarf2/*.c]] \ "" $DEFAULT_CFLAGS } diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp index 73c2c44..74136ae 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp @@ -35,7 +35,7 @@ set comp_output [gcc_target_compile \ if { ! [string match "*: target system does not support the * debug format*" \ $comp_output] } { remove-build-file "trivial.S" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \ + dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] $srcdir/c-c++-common/dwarf2/*.c]] \ "" $DEFAULT_CFLAGS } --------------070507000800070907030003--