summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-02-26 14:09:19 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2019-02-26 14:09:19 +0000
commit01c3ddcffb38e92e0f59aeb270e4848a5b8941f0 (patch)
tree8ddee9c1d54b069e4321c2f8d22abb607f4b4a61
parent302fe7500a45d9dbe0cdb292f62d7dcbacff9b56 (diff)
downloadgcc-01c3ddcffb38e92e0f59aeb270e4848a5b8941f0.tar.gz
re PR tree-optimization/89505 (LibreOffice miscompilation starting with r260383)
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
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr89505.c22
-rw-r--r--gcc/tree-ssa-structalias.c5
4 files changed, 38 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0c961dd37d7..c4260affdf7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
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
* tree-parloops.c (create_loop_fn): Copy over last_clique.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cc582c9e677..3f76c452764 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..6fca475ad9d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr89505.c
@@ -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;
+}
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 15f0872a2af..b92fcddfe9a 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -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;