From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: RFA: PATCH to expand_used_vars for debug/42800
Date: Fri, 19 Feb 2010 22:19:00 -0000 [thread overview]
Message-ID: <4B7F0E4E.4090902@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 810 bytes --]
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?
[-- Attachment #2: 42800.patch --]
[-- Type: text/x-patch, Size: 3273 bytes --]
commit 7b71cfa84b5c7e3c169f25e057789b5053a2b640
Author: Jason Merrill <jason@redhat.com>
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
}
[-- Attachment #3: 42800-2.patch --]
[-- Type: text/x-patch, Size: 2415 bytes --]
commit e0da647b68443f8c6b705aec72c5a6ffd26ae38a
Author: Jason Merrill <jason@redhat.com>
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
}
next reply other threads:[~2010-02-19 22:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-19 22:19 Jason Merrill [this message]
2010-02-19 22:34 ` Jakub Jelinek
2010-02-22 22:26 ` PING: PATCH to expand_used_vars for debug/42800 (P1 regression) Jason Merrill
2010-02-23 10:44 ` Richard Guenther
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B7F0E4E.4090902@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).