This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix declare_vars (PR debug/37726)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 3 Oct 2008 21:13:48 +0200
- Subject: [PATCH] Fix declare_vars (PR debug/37726)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Before tuples conversion declare_vars was using BIND_EXPR_BLOCK to
get BLOCK, which maps to gimple_bind_block, not gimple_block.
Typically scope is the outermost GIMPLE_BIND of a function and so
gimple_block (scope) is typically NULL, while gimple_bind_block is not.
This bug causes DECL_HAS_VALUE_EXPR_P vars created during nested pass
for debugging purposes not be emitted in BLOCK_VARS, which means
nothing is emitted in the debug info.
Bootstrapped/regtested on x86_64-linux, committed to trunk.
2008-10-03 Jakub Jelinek <jakub@redhat.com>
PR debug/37726
* gimplify.c (declare_vars): Use gimple_bind_block instead of
gimple_block.
* gcc.dg/debug/dwarf2/pr37726.c: New test.
--- gcc/gimplify.c.jj 2008-09-18 17:12:45.000000000 +0200
+++ gcc/gimplify.c 2008-10-03 16:33:40.000000000 +0200
@@ -772,7 +772,7 @@ declare_vars (tree vars, gimple scope, b
temps = nreverse (last);
- block = gimple_block (scope);
+ block = gimple_bind_block (scope);
gcc_assert (!block || TREE_CODE (block) == BLOCK);
if (!block || !debug_info)
{
--- gcc/testsuite/gcc.dg/debug/dwarf2/pr37726.c.jj 2008-10-03 16:43:28.000000000 +0200
+++ gcc/testsuite/gcc.dg/debug/dwarf2/pr37726.c 2008-10-03 16:48:26.000000000 +0200
@@ -0,0 +1,25 @@
+/* PR debug/37726 */
+/* { dg-do compile } */
+/* { dg-options "-g -O0 -dA -fno-merge-debug-strings" } */
+
+int foo (int parm)
+{
+ int var = 0;
+ int bar (void)
+ {
+ return parm + var;
+ }
+ parm++;
+ var++;
+ return bar ();
+}
+
+int
+main (void)
+{
+ return foo (4) - 6;
+}
+
+/* Both parm and var variables should be in debug info for both foo and bar. */
+/* { dg-final { scan-assembler-times "\"parm\[^\n\]*\"\[^\n\]*DW_AT_name" 2 } } */
+/* { dg-final { scan-assembler-times "\"var\[^\n\]*\"\[^\n\]*DW_AT_name" 2 } } */
Jakub