Richard Biener <rguent...@suse.de> writes:
> This makes same_type_for_tbaa_p conservative in the same way
> get_alias_set is about void * which we allow to alias all other
> pointers.
>
> Bootstrap & regtest running on x86_64-unknown-linux-gnu.
>
> Honza, is this what you had in mind?
>
> Thanks,
> Richard.
>
> 2020-04-14  Richard Biener  <rguent...@suse.de>
>
>       PR middle-end/94539
>       * tree-ssa-alias.c (same_type_for_tbaa): Handle void *
>       pointers the same as get_alias_set, returning -1.
>
>       * gcc.dg/alias-14.c: Make dg-do run.
> ---
>  gcc/testsuite/gcc.dg/alias-14.c | 2 +-
>  gcc/tree-ssa-alias.c            | 9 +++++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/testsuite/gcc.dg/alias-14.c b/gcc/testsuite/gcc.dg/alias-14.c
> index 1ca1c09d5e3..24f0d1c1168 100644
> --- a/gcc/testsuite/gcc.dg/alias-14.c
> +++ b/gcc/testsuite/gcc.dg/alias-14.c
> @@ -1,4 +1,4 @@
> -/* { dg-do compile } */
> +/* { dg-do run } */
>  /* { dg-options "-O2" } */
>  #include <stddef.h>
>  void *a;
> diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
> index df9ba0de0d6..2850141303e 100644
> --- a/gcc/tree-ssa-alias.c
> +++ b/gcc/tree-ssa-alias.c
> @@ -831,6 +831,15 @@ same_type_for_tbaa (tree type1, tree type2)
>        && TREE_CODE (type2) == ARRAY_TYPE)
>      return -1;
>  
> +  /* void * is compatible with all other pointers.  */
> +  if (POINTER_TYPE_P (type1)
> +      && POINTER_TYPE_P (type2)
> +      && (TREE_CODE (TREE_TYPE (type1)) == VOID_TYPE
> +       || TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (type1))
> +       || TREE_CODE (TREE_TYPE (type2)) == VOID_TYPE
> +       || TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (type2))))
> +    return -1;
> +

Could you add a comment about the TYPE_STRUCTURAL_EQUALITY_P checks?
Was surprised by them at first, since in aarch64 we use the flag to keep
a distinct ABI identity between ACLE vector types and other vector types.
I'm not sure we expected that to affect the aliasing rules between the
vector types and (say) arbitrary structures.

Thanks,
Richard

Reply via email to