This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix 28410


This was a bug in the alias pruning code.  We need to handle .GLOBAL_VAR
in access_can_touch_variable.  A memory reference that uses a
call-clobbered memory tag should always be considered to touch .GLOBAL_VAR.

Bootstrapped and tested on x86, x86-64 and ia64.


2006-07-18  Diego Novillo  <dnovillo@redhat.com>

	* tree-ssa-operands.c (access_can_touch_variable): Update
	comment.
	Return true if ALIAS is .GLOBAL_VAR.

testsuite/ChangeLog

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

Index: tree-ssa-operands.c
===================================================================
--- tree-ssa-operands.c	(revision 115551)
+++ tree-ssa-operands.c	(working copy)
@@ -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, tre
   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
Index: testsuite/gcc.dg/tree-ssa/pr28410.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/pr28410.c	(revision 0)
+++ testsuite/gcc.dg/tree-ssa/pr28410.c	(revision 0)
@@ -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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]