public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RFA: PATCH to expand_used_vars for debug/42800
@ 2010-02-19 22:19 Jason Merrill
  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
  0 siblings, 2 replies; 4+ messages in thread
From: Jason Merrill @ 2010-02-19 22:19 UTC (permalink / raw)
  To: gcc-patches List; +Cc: Jakub Jelinek

[-- 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
 }
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-02-23 10:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-19 22:19 RFA: PATCH to expand_used_vars for debug/42800 Jason Merrill
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

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).