This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix -fcompare-debug failures due to discover_nonconstant_array_refs (PR debug/43670)


Hi!

As can be seen on the attached testcase, discover_nonconstant_array_refs
could mark a variable as TREE_ADDRESSABLE just because of some use in
a debug stmt, which is undesirable.  For the time being we can just
give up on debug info in that case if a non-constant index is used into
an array hold in a register, later on perhaps we could do some subreg
+ shifts (with endian correction) + subreg dances.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.5?

2010-04-07  Jakub Jelinek  <jakub@redhat.com>

	PR debug/43670
	* cfgexpand.c (expand_debug_expr): If for non-NULL offset
	op0 is not a MEM, just return NULL instead of assertion
	failure.
	(discover_nonconstant_array_refs): Don't walk debug stmts.

	* gcc.dg/pr43670.c: New test.

--- gcc/cfgexpand.c.jj	2010-03-31 13:12:00.000000000 +0200
+++ gcc/cfgexpand.c	2010-04-07 19:44:12.000000000 +0200
@@ -2502,7 +2502,8 @@ expand_debug_expr (tree exp)
 	  {
 	    enum machine_mode addrmode, offmode;
 
-	    gcc_assert (MEM_P (op0));
+	    if (!MEM_P (op0))
+	      return NULL;
 
 	    op0 = XEXP (op0, 0);
 	    addrmode = GET_MODE (op0);
@@ -3623,7 +3624,8 @@ discover_nonconstant_array_refs (void)
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       {
 	gimple stmt = gsi_stmt (gsi);
-	walk_gimple_op (stmt, discover_nonconstant_array_refs_r, NULL);
+	if (!is_gimple_debug (stmt))
+	  walk_gimple_op (stmt, discover_nonconstant_array_refs_r, NULL);
       }
 }
 
--- gcc/testsuite/gcc.dg/pr43670.c.jj	2010-04-07 19:26:30.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr43670.c	2010-04-07 19:26:15.000000000 +0200
@@ -0,0 +1,29 @@
+/* PR debug/43670 */
+/* { dg-do compile } */
+/* { dg-options "-O -ftree-vrp -fcompare-debug" } */
+
+extern void abort (void);
+
+typedef struct { double T1; } S;
+
+void
+foo (void)
+{
+  int i, j;
+  double s;
+
+  S y[2][2];
+  S *x[2] = { y[0], y[1] };
+  S **p = x;
+
+  for (i = 0; i < 2; i++)
+    for (j = 0; j < 2; j++)
+      p[j][i].T1 = 1;
+
+  for (i = 0; i < 2; i++)
+    for (j = 0; j < 2; j++)
+      s = p[j][i].T1;
+
+  if (s != 1)
+    abort ();
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]