On Thu, 29 Oct 2020, Jan Hubicka wrote: > > Hi, > > this is patch I am using to fix the assumed_alias_type.f90 failure by > > simply arranging alias set 0 for the problematic array descriptor. > > > > I am not sure this is the best option, but I suppose it is better than > > setting all array descritors to have same canonical type (as done by > > LTO)? > > > Hi, > here is updated patch which used TYPELESS_STORAGE instead of alias set > 0, so it is LTO safe. Unforunately I also had to enable it for all > array descriptors otherwise I still get misopitmizations with modref > extended to handle bulitins, for example: > > FAIL: gfortran.dg/class_array_20.f03 -Os execution test > FAIL: gfortran.dg/coindexed_1.f90 -O2 execution test > FAIL: gfortran.dg/coindexed_1.f90 -O3 -fomit-frame-pointer > FAIL: gfortran.dg/coindexed_1.f90 -O3 -g execution test > > This is not a perfect solution (we really want to track array > descriptors), but it fixes wrong code and would let me to move forward. > Is it OK for mainline? > > With extended modref I still get infinite loop on pdt_14 testcase. > ipa-modref only performs disambiguation on > __vtab_link_module_Pdtlink_8._deallocate this global variable is > readonly (and is detected as such with LTO) so it must be just > uncovering some latent problem there. I am however not familiar enough > with Fortran to tell what is wrong there. > > The testcase fail different way with -flto for me. > > Bootstrapped/regtested x86_64-linux, OK?
OK. Thanks, Richard. > Honza > > * trans-types.c: Include alias.h > (gfc_get_array_type_bounds): Set typeless storage. > diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c > index b15ea667411..b7129dcbe6d 100644 > --- a/gcc/fortran/trans-types.c > +++ b/gcc/fortran/trans-types.c > @@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see > #include "trans-array.h" > #include "dwarf2out.h" /* For struct array_descr_info. */ > #include "attribs.h" > +#include "alias.h" > > > #if (GFC_MAX_DIMENSIONS < 10) > @@ -1903,6 +1904,10 @@ gfc_get_array_type_bounds (tree etype, int dimen, int > codimen, tree * lbound, > base_type = gfc_get_array_descriptor_base (dimen, codimen, false); > TYPE_CANONICAL (fat_type) = base_type; > TYPE_STUB_DECL (fat_type) = TYPE_STUB_DECL (base_type); > + /* Arrays of unknown type must alias with all array descriptors. */ > + TYPE_TYPELESS_STORAGE (base_type) = 1; > + TYPE_TYPELESS_STORAGE (fat_type) = 1; > + gcc_checking_assert (!get_alias_set (base_type) && !get_alias_set > (fat_type)); > > tmp = TYPE_NAME (etype); > if (tmp && TREE_CODE (tmp) == TYPE_DECL) >