re PR middle-end/91267 (SEGV in value_range_base::equal_p)
authorRichard Biener <rguenther@suse.de>
Mon, 29 Jul 2019 10:10:15 +0000 (10:10 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 29 Jul 2019 10:10:15 +0000 (10:10 +0000)
2019-07-29  Richard Biener  <rguenther@suse.de>

PR tree-optimization/91267
* vr-values.c (vr_values::update_value_range): Add early return
for effectively VARYING lattice entry.

* gcc.dg/torture/pr91267.c: New testcase.

From-SVN: r273874

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr91267.c [new file with mode: 0644]
gcc/vr-values.c

index 8cd321e..01e4666 100644 (file)
@@ -1,3 +1,9 @@
+2019-07-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91267
+       * vr-values.c (vr_values::update_value_range): Add early return
+       for effectively VARYING lattice entry.
+
 2019-07-29  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR debug/86638
index cc1aadf..3067162 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91267
+       * gcc.dg/torture/pr91267.c: New testcase.
+
 2019-07-29  Richard Sandiford  <richard.sandiford@arm.com>
 
        * c-c++-common/guality/Og-dce-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr91267.c b/gcc/testsuite/gcc.dg/torture/pr91267.c
new file mode 100644 (file)
index 0000000..084bd24
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+void bar (void);
+void baz (int);
+char *qux (void);
+int a, b;
+
+void
+foo (int f, char *d)
+{
+  char *e;
+  while (d)
+    {
+      if (f)
+       if (e)
+         bar ();
+      baz (e - (d + a));
+      b = e - d;
+      d = qux ();
+    }
+}
index d6a8847..d033099 100644 (file)
@@ -202,8 +202,12 @@ vr_values::update_value_range (const_tree var, value_range *new_vr)
        new_vr->intersect (&nr);
     }
 
-  /* Update the value range, if necessary.  */
+  /* Update the value range, if necessary.  If we cannot allocate a lattice
+     entry for VAR keep it at VARYING.  This happens when DOM feeds us stmts
+     with SSA names allocated after setting up the lattice.  */
   old_vr = get_lattice_entry (var);
+  if (!old_vr)
+    return false;
   is_new = !old_vr->equal_p (*new_vr, /*ignore_equivs=*/false);
 
   if (is_new)