diff mbox series

Fix PR83215, remove alias-set zero case from component_uses_parent_alias_set_from

Message ID alpine.LSU.2.20.1811191631480.1827@zhemvz.fhfr.qr
State New
Headers show
Series Fix PR83215, remove alias-set zero case from component_uses_parent_alias_set_from | expand

Commit Message

Richard Biener Nov. 19, 2018, 3:36 p.m. UTC
The PR complains that with TYPE_TYPELESS_STORAGE in C++ now too much
TBAA aliasing happens (not that this was unexpected).  The reason
for this with the testcase is the alias-set zero case in
component_uses_parent_alias_set_from which history tells me was added
for attribute((may_alias)) purposes - but that case is now handled
in the caller via ref_all_alias_ptr_type_p.  The TYPE_TYPELESS_STORAGE
case is also not needed given the flag is propagated in the type hierarchy
so if T is TYPE_TYPELESS_STORAGE then all bases are so as well.

Bootstrapped and tested on x86_64-unknown-linux-gnu for all languages.

Eric, do you know of any cases in Ada where a alias-set zero base
has non-alias-set zero children?  The testsuite seems to be clean
but you never know...

Richard.

2018-11-19  Richard Biener  <rguenther@suse.de>

	PR middle-end/83215
	* alias.c (component_uses_parent_alias_set_from): Remove
	alias-set zero and TYPE_TYPELESS_STORAGE case both already
	handled in other ways.

	* g++.dg/tree-ssa/pr83215.C: New testcase.

Comments

Eric Botcazou Nov. 19, 2018, 10:29 p.m. UTC | #1
> Eric, do you know of any cases in Ada where a alias-set zero base
> has non-alias-set zero children?  The testsuite seems to be clean
> but you never know...

No, at least not off the top of my head; that would be weird in any case.
Richard Biener Nov. 20, 2018, 8:13 a.m. UTC | #2
On Mon, 19 Nov 2018, Eric Botcazou wrote:

> > Eric, do you know of any cases in Ada where a alias-set zero base
> > has non-alias-set zero children?  The testsuite seems to be clean
> > but you never know...
> 
> No, at least not off the top of my head; that would be weird in any case.

OK, I'll bootstrap & test the change on the GCC 7 branch as well and if
there's no fallout there install it on trunk (only).  If anything pops
up we can easily revert.

Thanks,
Richard.
diff mbox series

Patch

Index: gcc/alias.c
===================================================================
--- gcc/alias.c	(revision 266278)
+++ gcc/alias.c	(working copy)
@@ -601,8 +601,7 @@  objects_must_conflict_p (tree t1, tree t
 /* Return the outermost parent of component present in the chain of
    component references handled by get_inner_reference in T with the
    following property:
-     - the component is non-addressable, or
-     - the parent has alias set zero,
+     - the component is non-addressable
    or NULL_TREE if no such parent exists.  In the former cases, the alias
    set of this parent is the alias set that must be used for T itself.  */
 
@@ -611,10 +610,6 @@  component_uses_parent_alias_set_from (co
 {
   const_tree found = NULL_TREE;
 
-  if (AGGREGATE_TYPE_P (TREE_TYPE (t))
-      && TYPE_TYPELESS_STORAGE (TREE_TYPE (t)))
-    return const_cast <tree> (t);
-
   while (handled_component_p (t))
     {
       switch (TREE_CODE (t))
@@ -652,9 +647,6 @@  component_uses_parent_alias_set_from (co
 	  gcc_unreachable ();
 	}
 
-      if (get_alias_set (TREE_TYPE (TREE_OPERAND (t, 0))) == 0)
-	found = t;
-
       t = TREE_OPERAND (t, 0);
     }
  
Index: gcc/testsuite/g++.dg/tree-ssa/pr83215.C
===================================================================
--- gcc/testsuite/g++.dg/tree-ssa/pr83215.C	(nonexistent)
+++ gcc/testsuite/g++.dg/tree-ssa/pr83215.C	(working copy)
@@ -0,0 +1,19 @@ 
+// { dg-do compile }
+// { dg-options "-O2 -fdump-tree-fre1" }
+
+struct mytest
+{
+  float a;
+  char buf[256];
+};
+
+int foo(mytest *m, int *i)
+{
+  int tmp = *i;
+  m->a = 10.0f;
+  return tmp + *i;
+}
+
+// we should be able to CSE *i despite mytest having a cbar[] buffer
+// and thus being subject to TYPE_TYPELESS_STORAGE
+// { dg-final { scan-tree-dump-times "\\*i" 1 "fre1" } }