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]

Re: Incorrect bitfield aliasing with Tree SSA


Daniel Berlin writes:
> HMm, i'd just record it for all of them, since the are accessible
> through a pointer to the structure.

Here it is.  I added a comment which hopefully summarizes the
situation to everybody's satisfaction.

Eric, does this you think qualifies as a fix for PR 25737.  You had
the same fix proposed in the PR so I would think so.

Bootstrapped and tested on x86_64-linux.

OK?  Also is it OK for 4.1 and 4.2 after some time?

Adam

	* alias.c (record_component_aliases): Call record_alias_subset for
	DECL_NONADDRESSABLE_P fields too.

testsuite/:

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

Index: alias.c
===================================================================
--- alias.c	(revision 125588)
+++ alias.c	(working copy)
@@ -756,7 +756,11 @@ record_component_aliases (tree type)
 				 get_alias_set (BINFO_TYPE (base_binfo)));
 	}
       for (field = TYPE_FIELDS (type); field != 0; field = TREE_CHAIN (field))
-	if (TREE_CODE (field) == FIELD_DECL && ! DECL_NONADDRESSABLE_P (field))
+	/* We used to skip DECL_NONADDRESSABLE_P fields here.  That is
+	   not valid on Tree SSA but valid on RTL where such fields
+	   are accessed under alias set 0 or under the alias set of
+	   the containing aggregate.  */
+	if (TREE_CODE (field) == FIELD_DECL)
 	  record_alias_subset (superset, get_alias_set (TREE_TYPE (field)));
       break;
 
Index: testsuite/gcc.dg/tree-ssa/alias-14.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/alias-14.c	(revision 0)
+++ testsuite/gcc.dg/tree-ssa/alias-14.c	(revision 0)
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+struct s
+{
+  long long a:12;
+  long long b:12;
+  long long c:40;
+};
+
+struct s s, *p = &s;
+
+int
+main ()
+{
+  p->a = 1;
+  s.a = 0;
+  s.b = 0;
+  return p->a + s.b;
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]