PR debug/42715
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Jan 2010 00:42:02 +0000 (00:42 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Jan 2010 00:42:02 +0000 (00:42 +0000)
* var-tracking.c (use_type): Choose MO_VAL_SET for REGs set
without a cselib val.
(count_uses): Accept MO_VAL_SET with no val on stores.
(add_stores): Likewise.

* gcc.dg/pr42715.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156102 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr42715.c [new file with mode: 0644]
gcc/var-tracking.c

index 6726e44..4ec8ee6 100644 (file)
@@ -1,3 +1,11 @@
+2010-01-20  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR debug/42715
+       * var-tracking.c (use_type): Choose MO_VAL_SET for REGs set
+       without a cselib val.
+       (count_uses): Accept MO_VAL_SET with no val on stores.
+       (add_stores): Likewise.
+
 2010-01-20  Jakub Jelinek  <jakub@redhat.com>
 
        * var-tracking.c (check_value_val): Add a compile time assertion.
index 76d2bc5..0fac516 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-20  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR debug/42715
+       * gcc.dg/pr42715.c: New.
+
 2010-01-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/42038
diff --git a/gcc/testsuite/gcc.dg/pr42715.c b/gcc/testsuite/gcc.dg/pr42715.c
new file mode 100644 (file)
index 0000000..72bdfc8
--- /dev/null
@@ -0,0 +1,59 @@
+/* { dg-do compile { target fpic } } */
+/* { dg-options "-fPIC -g -O2 -w" } */
+/* var-tracking failed to clobber the reg holding v at the asm insn,
+   so v ended up bound to an intermediate PIC expression.  */
+
+struct A { unsigned a1; char a2[15]; };
+struct B { long b1; unsigned char b2; long b3; };
+struct C { void *c1; unsigned c2; unsigned c3; };
+
+static struct A v1;
+struct A *const v2 = &v1;
+
+static inline
+int foo (void)
+{
+  int *v;
+  __asm__ __volatile__ ("" : "=r" (v));
+  return v[1];
+}
+
+static void
+bar (struct C *x)
+{
+  if (x->c2 == x->c3 && x->c1)
+    f1 (foo (), x->c1, x->c3 * sizeof (x->c1[0]));
+}
+
+void
+baz (struct B *y)
+{
+  int i;
+  const char *j;
+  char *k;
+  char x[64];
+  for (i = 0; i < sizeof (struct B); i++, y)
+    {
+      switch (y->b2)
+        {
+        case 0x20:
+          if (__builtin_strchr (j, '='))
+            continue;
+        }
+      switch (y->b2)
+        {
+        case 0x80:
+          bar (&x);
+          f2 (y->b3);
+        case 0x2e:
+        case 0x4e:
+          break;
+        default:
+          if (v2->a1)
+            f2 (y->b2);
+        }
+      k[0] = '\0';
+      if (v2->a1)
+        f2 (y->b1);
+    }
+}
index 5ac3222..79e8d56 100644 (file)
@@ -4426,7 +4426,6 @@ static enum micro_operation_type
 use_type (rtx loc, struct count_use_info *cui, enum machine_mode *modep)
 {
   tree expr;
-  cselib_val *val;
 
   if (cui && cui->sets)
     {
@@ -4447,19 +4446,24 @@ use_type (rtx loc, struct count_use_info *cui, enum machine_mode *modep)
            return MO_CLOBBER;
        }
 
-      if ((REG_P (loc) || MEM_P (loc))
-         && (val = find_use_val (loc, GET_MODE (loc), cui)))
+      if (REG_P (loc) || MEM_P (loc))
        {
          if (modep)
            *modep = GET_MODE (loc);
          if (cui->store_p)
            {
              if (REG_P (loc)
-                 || cselib_lookup (XEXP (loc, 0), GET_MODE (loc), 0))
+                 || (find_use_val (loc, GET_MODE (loc), cui)
+                     && cselib_lookup (XEXP (loc, 0), GET_MODE (loc), 0)))
                return MO_VAL_SET;
            }
-         else if (!cselib_preserved_value_p (val))
-           return MO_VAL_USE;
+         else
+           {
+             cselib_val *val = find_use_val (loc, GET_MODE (loc), cui);
+
+             if (val && !cselib_preserved_value_p (val))
+               return MO_VAL_USE;
+           }
        }
     }
 
@@ -4580,7 +4584,8 @@ count_uses (rtx *ploc, void *cuip)
              cselib_preserve_value (val);
            }
          else
-           gcc_assert (mopt == MO_VAL_LOC);
+           gcc_assert (mopt == MO_VAL_LOC
+                       || (mopt == MO_VAL_SET && cui->store_p));
 
          break;
 
@@ -4968,6 +4973,9 @@ add_stores (rtx loc, const_rtx expr, void *cuip)
 
   v = find_use_val (oloc, mode, cui);
 
+  if (!v)
+    goto log_and_return;
+
   resolve = preserve = !cselib_preserved_value_p (v);
 
   nloc = replace_expr_with_values (oloc);