[PATCH] Fix ICE in expand_debug_expr with -combine (PR debug/41893)

Jakub Jelinek jakub@redhat.com
Mon Nov 2 13:14:00 GMT 2009


Hi!

On this testcase s has incomplete type in the second TU, but is not
DECL_EXTERNAL (as the same symbol name is defined in the first TU).
We shouldn't try to create a DECL_RTL in that case.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for
trunk?

2009-11-02  Jakub Jelinek  <jakub@redhat.com>

	PR debug/41893
	* cfgexpand.c (expand_debug_expr): Don't attempt to create DECL_RTL
	for a VOIDmode variable.

	* gcc.dg/debug/pr41893-1.c: New test.
	* gcc.dg/debug/pr41893-2.c: New file.

--- gcc/cfgexpand.c.jj	2009-10-26 14:01:33.000000000 +0100
+++ gcc/cfgexpand.c	2009-11-02 10:57:00.000000000 +0100
@@ -2346,7 +2346,8 @@ expand_debug_expr (tree exp)
 	      || DECL_EXTERNAL (exp)
 	      || !TREE_STATIC (exp)
 	      || !DECL_NAME (exp)
-	      || DECL_HARD_REGISTER (exp))
+	      || DECL_HARD_REGISTER (exp)
+	      || mode == VOIDmode)
 	    return NULL;
 
 	  op0 = DECL_RTL (exp);
--- gcc/testsuite/gcc.dg/debug/pr41893-1.c.jj	2009-11-02 11:03:45.000000000 +0100
+++ gcc/testsuite/gcc.dg/debug/pr41893-1.c	2009-11-02 11:03:16.000000000 +0100
@@ -0,0 +1,13 @@
+/* PR debug/41893 */
+/* { dg-do compile } */
+/* { dg-options "-combine -fwhole-program -O" } */
+/* { dg-additional-sources "pr41893-2.c" } */
+
+struct S { int v; };
+struct S s;
+
+void __attribute__((externally_visible))
+func1 (void)
+{
+  struct S *p = &s;
+}
--- gcc/testsuite/gcc.dg/debug/pr41893-2.c.jj	2009-11-02 11:03:48.000000000 +0100
+++ gcc/testsuite/gcc.dg/debug/pr41893-2.c	2009-11-02 11:03:23.000000000 +0100
@@ -0,0 +1,10 @@
+/* PR debug/41893 */
+/* { dg-do compile } */
+
+extern struct S s;
+
+void
+func2 (void)
+{
+  &s;
+}

	Jakub



More information about the Gcc-patches mailing list