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: Thu, 28 May 2015 16:09:25 +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> <20150527144221 dot GB51385 at kam dot mff dot cuni dot cz> <20150527145821 dot GC51385 at kam dot mff dot cuni dot cz> <20150527150413 dot GD51385 at kam dot mff dot cuni dot cz> <5B58CC66-6A43-401E-9A83-A26D076D2A45 at suse dot de> <20150528132943 dot GA8474 at kam dot mff dot cuni dot cz> <alpine dot LSU dot 2 dot 11 dot 1505281544250 dot 30088 at zhemvz dot fhfr dot qr>
> > +alias_set_entry
> > +init_alias_set_entry (alias_set_type set)
> > +{
> > + alias_set_entry ase = ggc_cleared_alloc<alias_set_entry_d> ();
>
> no need to use cleared_alloc if you also init ->is_pointer to false.
OK, will update the patch.
>
> > + ase->alias_set = set;
> > + ase->children
> > + = hash_map<int, int, alias_set_traits>::create_ggc (64);
>
> that seems a bit excessive, esp. for pointers which won't end
> up with any children? So better make children lazily allocated
> in record_alias_subset.
All pointers that are not in alias set of ptr_type_node will have a child.
So there is only one childless pointer set. I will update the code though.
>
> I still wonder why you do this instead of changing alias_sets_conflict
> in the same way you changed alias_set_subset_of.
Because I would need two flags otherwise. One denoting alias sets that
are pointers (who needs special treatment for subset_of) and one denoting
alias set that contains pointer.
i.e. for:
struct {int *a,b;}
I need to have its alias set to contain all of setof(int), setof(int *), setof(void *).
I however do not want setof(struct {int *a,b;}) to be subset of setof(void *)
Honza
>
> Patch looks ok otherwise but please leave the patch for others to
> comment on for a while.
>
> Thanks,
> Richard.
>
> > + }
> > + }
> > + }
> > + /* In LTO the rules above needs to be part of canonical type machinery.
> > + For now just punt. */
> > + else if (POINTER_TYPE_P (t) && t != ptr_type_node && in_lto_p)
> > set = get_alias_set (ptr_type_node);
> >
> > /* Otherwise make a new alias set for this type. */
> > @@ -953,6 +1052,15 @@ get_alias_set (tree t)
> > if (AGGREGATE_TYPE_P (t) || TREE_CODE (t) == COMPLEX_TYPE)
> > record_component_aliases (t);
> >
> > + /* We treat pointer types specially in alias_set_subset_of. */
> > + if (POINTER_TYPE_P (t) && set)
> > + {
> > + alias_set_entry ase = get_alias_set_entry (set);
> > + if (!ase)
> > + ase = init_alias_set_entry (set);
> > + ase->is_pointer = true;
> > + }
> > +
> > return set;
> > }
> >
> > @@ -1003,12 +1111,7 @@ record_alias_subset (alias_set_type supe
> > {
> > /* Create an entry for the SUPERSET, so that we have a place to
> > attach the SUBSET. */
> > - superset_entry = ggc_cleared_alloc<alias_set_entry_d> ();
> > - superset_entry->alias_set = superset;
> > - superset_entry->children
> > - = hash_map<int, int, alias_set_traits>::create_ggc (64);
> > - superset_entry->has_zero_child = 0;
> > - (*alias_sets)[superset] = superset_entry;
> > + superset_entry = init_alias_set_entry (superset);
> > }
> >
> > if (subset == 0)
> > Index: testsuite/gcc.dg/alias-8.c
> > ===================================================================
> > --- testsuite/gcc.dg/alias-8.c (revision 223772)
> > +++ testsuite/gcc.dg/alias-8.c (working copy)
> > @@ -8,5 +8,5 @@ struct s {
> > void
> > func(struct s *ptr)
> > {
> > - *(void **)&ptr->p = 0; /* { dg-warning "type-punned pointer" "" { xfail *-*-* } } */
> > + *(void **)&ptr->p = 0; /* { dg-warning "type-punned pointer" "" { } } */
> > }
> > Index: testsuite/gcc.dg/pr62167.c
> > ===================================================================
> > --- testsuite/gcc.dg/pr62167.c (revision 223772)
> > +++ testsuite/gcc.dg/pr62167.c (working copy)
> > @@ -29,6 +29,8 @@ main ()
> >
> > node.prev = (void *)head;
> >
> > + asm("":"=m"(node.prev));
> > +
> > head->first = &node;
> >
> > struct node *n = head->first;
> >
> >
>
> --
> Richard Biener <rguenther@suse.de>
> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nuernberg)