On Tue, 29 Sep 2015, Tom de Vries wrote:
> On 22/09/15 09:49, Richard Biener wrote:
> > On Tue, 22 Sep 2015, Tom de Vries wrote:
> >
> > > Hi,
> > >
> > > Consider this test-case:
> > >
> > > struct ps
> > > {
> > > int *__restrict__ p;
> > > };
> > >
> > > void
> > > f (struct ps &__restrict__ ps1)
> > > {
> > > *(ps1.p) = 1;
> > > }
> > >
> > >
> > > Atm, the restrict on p has no effect. Now, say we add a field to the
> > > struct:
> > >
> > > struct ps
> > > {
> > > int *__restrict__ p;
> > > int a;
> > > };
> > >
> > >
> > > Then the restrict on p does have the desired effect.
> > >
> > >
> > > This patch fixes the handling of structs with a single field in alias
> > > analysis.
> > >
> > > Bootstrapped and reg-tested on x86_64.
> > >
> > > OK for trunk?
> >
> > Ok.
> >
>
> Hi,
>
> I wonder if this follow-up patch is necessary.
>
> Now that we handle structs with one field in the final loop of
> create_variable_info_for_1, should we set the is_full_var field as well? It
> used to be set for such structs before I committed the "Handle single restrict
> pointer in struct in create_variable_info_for_1" patch.
Yeah, I suppose so. But I'd set vi->is_full_var to true when
allocating 'vi':
vi = new_var_info (decl, name);
vi->fullsize = tree_to_uhwi (declsize);
+ if (fieldstack.length () == 1)
+ vi->is_full_var = true;
Ok with that change.
Thanks,
Richard.
> Thanks,
> - Tom
>
> diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
> index 8d86dcb..26d97a3 100644
> --- a/gcc/tree-ssa-structalias.c
> +++ b/gcc/tree-ssa-structalias.c
> @@ -5720,6 +5720,8 @@ create_variable_info_for_1 (tree decl, const char *name)
> newvi->offset = fo->offset;
> newvi->size = fo->size;
> newvi->fullsize = vi->fullsize;
> + if (fieldstack.length () == 1)
> + newvi->is_full_var = true;
> newvi->may_have_pointers = fo->may_have_pointers;
> newvi->only_restrict_pointers = fo->only_restrict_pointers;
> if (i + 1 < fieldstack.length ())
>
>
--
Richard Biener <[email protected]>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB
21284 (AG Nuernberg)