diff mbox series

Fix PR89505

Message ID alpine.LSU.2.20.1902261505330.23386@zhemvz.fhfr.qr
State New
Headers show
Series Fix PR89505 | expand

Commit Message

Richard Biener Feb. 26, 2019, 2:06 p.m. UTC
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk 
sofar.

Richard.

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.

Comments

Matthias Klose March 21, 2019, 12:28 p.m. UTC | #1
On 26.02.19 15:06, Richard Biener wrote:
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk 
> sofar.

That was backported to the gcc-8 branch, and now Richard approved the backport
the gcc-7 branch.

Matthias
diff mbox series

Patch

Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c	(revision 269205)
+++ gcc/tree-ssa-structalias.c	(working copy)
@@ -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;
Index: gcc/testsuite/gcc.dg/torture/pr89505.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr89505.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr89505.c	(working copy)
@@ -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;
+}