]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/89505 (LibreOffice miscompilation starting with...
authorMatthias Klose <doko@ubuntu.com>
Thu, 21 Mar 2019 12:28:26 +0000 (12:28 +0000)
committerMatthias Klose <doko@gcc.gnu.org>
Thu, 21 Mar 2019 12:28:26 +0000 (12:28 +0000)
2019-03-21  Matthias Klose  <doko@ubuntu.com>

        Backport from mainline
        2019-02-26  Richard Biener  <rguenther@suse.de>

        PR tree-optimization/89505
        * tree-ssa-structalias.c (compute_dependence_clique): Make sure
        to handle restrict pointed-to vars with multiple subvars
        correctly.

2019-03-21  Matthias Klose  <doko@ubuntu.com>

        Backport from mainline
        2019-02-26  Richard Biener  <rguenther@suse.de>

        PR tree-optimization/89505
        * gcc.dg/torture/pr89505.c: New testcase.

From-SVN: r269836

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr89505.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index b24bc2fe0e6abd1912252e3ad295b77daab5cc72..cfcf569785fd77ff9e75743454857b6f53f4f70d 100644 (file)
@@ -1,3 +1,13 @@
+2019-03-21  Matthias Klose  <doko@ubuntu.com>
+
+       Backport from mainline
+       2019-02-26  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89505
+       * tree-ssa-structalias.c (compute_dependence_clique): Make sure
+       to handle restrict pointed-to vars with multiple subvars
+       correctly.
+
 2019-03-17  H.J. Lu  <hongjiu.lu@intel.com>
 
        Backport from mainline
index 53aaf96cc17c744580bc079cc76b3899aeed4e01..28756b1f6beed27b77ee92c59c722a5830f34519 100644 (file)
@@ -1,3 +1,11 @@
+2019-03-21  Matthias Klose  <doko@ubuntu.com>
+
+       Backport from mainline
+       2019-02-26  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89505
+       * gcc.dg/torture/pr89505.c: New testcase.
+
 2019-03-17  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/84394
diff --git a/gcc/testsuite/gcc.dg/torture/pr89505.c b/gcc/testsuite/gcc.dg/torture/pr89505.c
new file mode 100644 (file)
index 0000000..6fca475
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+
+struct S { int i; void *p; int j; };
+int a;
+int __attribute__((noinline))
+foo (struct S * __restrict p, int q)
+{
+  int *x = &p->j;
+  if (q)
+    x = &a;
+  p->j = 1;
+  *x = 2;
+  return p->j;
+}
+
+int main()
+{
+  struct S s;
+  if (foo (&s, 0) != 2)
+    __builtin_abort ();
+  return 0;
+}
index b5a5f0f54d195fc3759b222a2ea7e8d94da06a74..bffa7dad4b49d99ac3cd898a0180db8f3e506673 100644 (file)
@@ -7456,7 +7456,10 @@ compute_dependence_clique (void)
            }
          if (used)
            {
-             bitmap_set_bit (rvars, restrict_var->id);
+             /* Add all subvars to the set of restrict pointed-to set. */
+             for (unsigned sv = restrict_var->head; sv != 0;
+                  sv = get_varinfo (sv)->next)
+               bitmap_set_bit (rvars, sv);
              varinfo_t escaped = get_varinfo (find (escaped_id));
              if (bitmap_bit_p (escaped->solution, restrict_var->id))
                escaped_p = true;