This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix aliasing problem with fortran


Hello,

> > 	* trans-types.c (gfc_array_range_type): New variable.
> > 	(gfc_init_types): Initialize gfc_array_range_type.
> > 	(gfc_get_array_type_bounds): Use gfc_array_range_type.
> 
> I don't believe this is sufficient. For example:
> 
> program prog
> integer, dimension(5) :: a
>   a(1) = 1;
>   call foo(a)
>   if (a(1) .ne. 0) call abort()
> contains
> subroutine foo(p)
>   integer p(3)
> 
>   p(1) = 0;
> end subroutine
> end program
> 
> 
> Both with and without your patch this compiles to (from the .gimple dump):
> 
>   int4 a[5];
> ...
>     int4[3] * p;
>     p = (int4[3] *) &a;
> accesses to both a and *p

here this should not be a problem -- you only access the elements of the
arrays and the type based aliasing of rtl thus sees both accesses as
integers and correctly decides that they may alias.

The problem in my testcase is that the array is multidimensional, thus
its dimensions etc. are described in a structure:

  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.

Zdenek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]