re PR tree-optimization/28410 (Wrong aliasing with global var grouping during call...
authorDiego Novillo <dnovillo@redhat.com>
Tue, 18 Jul 2006 17:27:57 +0000 (17:27 +0000)
committerDiego Novillo <dnovillo@gcc.gnu.org>
Tue, 18 Jul 2006 17:27:57 +0000 (13:27 -0400)
PR 28410
* tree-ssa-operands.c (access_can_touch_variable): Update
comment.
Return true if ALIAS is .GLOBAL_VAR.

testsuite/ChangeLog

PR 28410
* gcc.dg/tree-ssa/pr28410.c: New test.

From-SVN: r115564

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr28410.c [new file with mode: 0644]
gcc/tree-ssa-operands.c

index f64d3f2290f74be195db0383c05dfdbd9cbe7cf8..435f32508eb8dee89c6948cbd9fe2d30fb27d3f4 100644 (file)
@@ -1,3 +1,10 @@
+2006-07-18  Diego Novillo  <dnovillo@redhat.com>
+
+       PR 28410
+       * tree-ssa-operands.c (access_can_touch_variable): Update
+       comment.
+       Return true if ALIAS is .GLOBAL_VAR.
+
 2006-07-18  David Daney  <ddaney@avtrex.com>
 
        * gcc.c (display_help): Fix typo in help text.
index 2025aadbacc2cf1cadcddc75d005fe2f96b92119..505a2adcaf4454ab2a0d18877c482277093d6c50 100644 (file)
@@ -1,3 +1,8 @@
+2006-07-18  Diego Novillo  <dnovillo@redhat.com>
+
+       PR 28410
+       * gcc.dg/tree-ssa/pr28410.c: New test.
+
 2006-07-18  Lee Millward  <lee.millward@gmail.com>
 
        PR c++/28258
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr28410.c b/gcc/testsuite/gcc.dg/tree-ssa/pr28410.c
new file mode 100644 (file)
index 0000000..12f0633
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-options "-O2 --param global-var-threshold=1" } */
+
+extern void abort(void);
+struct Bar { int p; };
+struct Foo { struct Bar *p; };
+struct Bar p0 = { 0 };
+struct Bar p1 = { 1 };
+void bar(struct Foo *f)
+{
+  f->p = &p0;
+}
+int foo(struct Foo *f)
+{
+  f->p->p = 1;
+  bar(f);
+  return f->p->p;
+}
+int main()
+{
+  struct Foo f;
+  f.p = &p1;
+  if (foo(&f) != 0)
+    abort ();
+  return 0;
+}
index 3cd8c45aaf1d444e38d2cb5971249e98c4e0716a..05637814f13151162b784d5409cfc80b9af895c3 100644 (file)
@@ -1037,9 +1037,7 @@ append_v_must_def (tree var)
 /* REF is a tree that contains the entire pointer dereference
    expression, if available, or NULL otherwise.  ALIAS is the variable
    we are asking if REF can access.  OFFSET and SIZE come from the
-   memory access expression that generated this virtual operand.
-   FOR_CLOBBER is true is this is adding a virtual operand for a call
-   clobber.  */
+   memory access expression that generated this virtual operand.  */
 
 static bool
 access_can_touch_variable (tree ref, tree alias, HOST_WIDE_INT offset,
@@ -1049,6 +1047,12 @@ access_can_touch_variable (tree ref, tree alias, HOST_WIDE_INT offset,
   unsigned HOST_WIDE_INT uoffset = (unsigned HOST_WIDE_INT) offset;
   tree base = ref ? get_base_address (ref) : NULL;
 
+  /* If ALIAS is .GLOBAL_VAR then the memory reference REF must be
+     using a call-clobbered memory tag.  By definition, call-clobbered
+     memory tags can always touch .GLOBAL_VAR.  */
+  if (alias == global_var)
+    return true;
+
   /* If ALIAS is an SFT, it can't be touched if the offset     
      and size of the access is not overlapping with the SFT offset and
      size.  This is only true if we are accessing through a pointer