This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Do less generous pointer globbing in alias.c
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Richard Biener <rguenther at suse dot de>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 27 May 2015 16:42:21 +0200
- Subject: Re: Do less generous pointer globbing in alias.c
- Authentication-results: sourceware.org; auth=none
- References: <20150527052850 dot GB88897 at kam dot mff dot cuni dot cz> <alpine dot LSU dot 2 dot 11 dot 1505271046320 dot 30088 at zhemvz dot fhfr dot qr>
> > Hi, this patch makes it possible for non-LTO alias oracle to TBAA
> > disambiguate pointer types. It makes void * conflicting with all of them
> > and does not put it to alias set 0. It also preserves the property that
> > qualifiers of pointer-to type should not matter to determine the alias
> > set and that pointer to array is same as pointer to array element.
> > Finally it makes pointer void * to be equivalent to void ** (and more *)
> > and to types with structural equality only.
>
> void * should be equivalent to incomplete-type * as well.
It will be in conflict with struct FOO * when FOO is incomplete.
In non-LTO build struct FOO * do not need to conflict wqith struct BAR *.
Or do I miss something here?
>
> > I think those are all globbing rules we discussed for the non-LTO patch.
> >
> > It does two things. First is kind of "canonicalization" where for a given pointer
> > it looks for non-pointer pointed-to type and then rebuilds is without qualifiers.
> > This is fast, because build_pointer_type will reuse existing types.
> >
> > It makes void * to conflict with everyting by making its alias set to be subset
> > of alias set of any other pointer. This means that writes to void * conflict
> > with writes to any other pointer without really need to glob all the pointers
> > to one equivalence class.
>
> I think you need to make each pointer alias-set a subset of the one of
> void * as well because both of the following is valid:
>
> *(void *)p = ...
> ... = *(int *)p;
>
> and
>
> *(int *)p = ...
> ... = *(void *)p;
Yes, so is
struct foo {struct bar a;};
a.a = ...
... = a;
and
a = ...
... = a.a;
this is why conflict is symmetrization of the subset relation.
You can not record both edges into the DAG, because record_alias_subset
compute transitive closure and it would end up in loop. I will be hapy
to add the extra flag (has_zero_child), but I would like to make it
clear it an optimization.
>
> not sure if it's possible to create a testcase that fails if you do
> subsetting only one-way (because alias_sets_conflict queries both
> ways and I think alias_set_subset_of is not used very much, only
> by tree-ssa-alias.c:aliasing_component_refs_p which won't ever
> use it on two pointer alias sets). In theory true vs. anti-dependence
Yep, I noticed that subsets are querried by tree-ssa-alias. I will try to
think if it is safe WRT the code above.
> should use alias_set_subset_of and trigger the above cases. But
> as those queries are done wrong a lot (in the past?) we use
> alias_sets_conflict there.
>
> For efficiency you could use a new flag similar to has_zero_child
> in alias_set_entry_d ...
Yes, I can use new flag, but it should be unnecesary. The alias set 0
is also just common subset of all aliases (that is not done by the code).
>
> I see no reason for punting for LTO here.
I would rather go with non-LTO first and work on solving the canonical type
issues. Yes, I think it should work for LTO as it is and I bootstrapped and
regtested it. I only wanted to do one step at a time.
What I do not like is that build_pointer_type simply does not do the right
thing here. Consdier
struct a {int a};
struct b {char b};
Now if you LTO in struct *a and struct *b their canonical type will be the same.
If you call build_pointer_type, it will assign different canonical types to them.
This does not lead to wrong code, because incomplete types no longer get
TYPE_CANONICAL, but I would like first to chase out the bugs out of canonical
type computation and arrange middle-end build pointer types to be the same as
LTOed-in pointer types.
>
> Btw, please check if SPEC perl still works without -fno-strict-aliasing
> (it finally did after the change to do pointer globbing).
OK, I have SPEC perl available, so I will do.
I am teaching now, but so will reply in detail afterwards. I was just hoping
to discuss the symmetry thing above. I think it is not needed.
I have no problem with moving the subset code to get_alias_set and will update
the patch (including testsuite compensation).
Honza