[patch] Fix aliasing problem with fortran

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Tue May 17 00:23:00 GMT 2005


Hello,

> >   int4 a[10];
> >   int4[0:] * b.0;
> >   struct array2_int4 & b;
> >   struct array2_int4 parm.9;
> >
> >   ...
> >   D.517 = (int4[0:] *) &a[0];
> >   parm.9.data = D.517;
> >   b = (struct array2_int4 &) &parm.9;
> >   ...
> >   b.0 = (int4[0:] *) b->data;
> >
> > Without my patch, b->data and parm.9.data have different types,
> > thus there is no dependence between the load and the store to data.
> 
> Oh! you mean PR16898?

now that you mention it, I have

Tests that now work, but didn't before:
gfortran.dg/ret_pointer_1.f90  -O2  execution test
gfortran.dg/ret_pointer_1.f90  -O3 -g  execution test
gfortran.dg/ret_pointer_1.f90  -Os  execution test

with the patch; so it might in fact fix this PR.

> Even with your patch, don't *b and param.9 have different types?

Probably, I did not look. 

> In which case 
> couldn't the problem still occur, even if the data fields happen to have the 
> same type?

I think not with the current RTL alias analysis, since the fact that
types of the fields are equal and that the structures match should be
sufficient for it to work correctly.

> It might not occur now, but I guess it could if we start passing 
> alias information down from trees to rtl.

This might be the case; if so, the types would have to be shared
completely to avoid this problem.

Zdenek



More information about the Gcc-patches mailing list