re PR tree-optimization/89505 (LibreOffice miscompilation starting with r260383)
authorRichard Biener <rguenther@suse.de>
Tue, 26 Feb 2019 14:09:19 +0000 (14:09 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 26 Feb 2019 14:09:19 +0000 (14:09 +0000)
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.

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

From-SVN: r269212

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

index 0c961dd37d790a0135ee987c050acc3b8ad7d043..c4260affdf7fc2961a04564510e8659160c65443 100644 (file)
@@ -1,3 +1,10 @@
+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-02-26  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/89489
index cc582c9e6776a33805cb0b93d6e0b93689334812..3f76c4527643f6dd3804d0f09d8e18f8d077db4e 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-26  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89505
+       * gcc.dg/torture/pr89505.c: New testcase.
+
 2019-02-26  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/opt77.adb: New test.
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 15f0872a2af4375bac61ea95609ea3546338cf4f..b92fcddfe9a6fb458530ba20a24f0373d3dce842 100644 (file)
@@ -7613,7 +7613,10 @@ compute_dependence_clique (void)
                                              maybe_set_dependence_info);
          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;