From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id DA9EB386F430; Sun, 27 Sep 2020 21:37:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DA9EB386F430 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=hubicka@kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 368E6282ADB; Sun, 27 Sep 2020 23:37:40 +0200 (CEST) Date: Sun, 27 Sep 2020 23:37:40 +0200 From: Jan Hubicka To: Tobias Burnus Cc: Richard Biener , gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: Re: New modref/ipa_modref optimization passes Message-ID: <20200927213740.GA52458@kam.mff.cuni.cz> References: <157394261677.27454.2367573047582814412@a285.localdomain> <20200919223255.GA69342@kam.mff.cuni.cz> <20200920061551.GA29500@kam.mff.cuni.cz> <20200921074752.GD91738@kam.mff.cuni.cz> <20200921080447.GE6758@kam.mff.cuni.cz> <7ed1450c-68e1-a61a-307f-f07a474225e9@net-b.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7ed1450c-68e1-a61a-307f-f07a474225e9@net-b.de> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Sep 2020 21:37:45 -0000 > On 9/21/20 10:10 AM, Richard Biener wrote: > > > > I see, so you would expect call to alsize to initialize things in > > > array15_unkonwn type? That would work too. > > Yes, that's my expectation. But let's see what fortran folks say. > > RFC patch attached; I think the following should work, but I am not > sure whether I missed something. > > I wonder what to do about > '!GCC$ NO_ARG_CHECK :: x > but that seems to work fine (creates void* type) and as it only > permits assumed size or scalar variables, the descriptor issue > does not occur. > > Thoughts? Hi, with somewhat improved ipa-modref and your patch i get following failures: FAIL: gfortran.dg/assumed_type_2.f90 -O scan-tree-dump-times original "sub_array_assumed \\\\(\\\\(struct t1.0:. .\\\\) parm" 1 FAIL: gfortran.dg/assumed_type_9.f90 -O2 execution test FAIL: gfortran.dg/assumed_type_9.f90 -Os execution test FAIL: gfortran.dg/class_allocate_20.f90 -O2 execution test FAIL: gfortran.dg/class_allocate_20.f90 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gfortran.dg/class_allocate_20.f90 -O3 -g execution test FAIL: gfortran.dg/class_allocate_20.f90 -Os execution test FAIL: gfortran.dg/finalize_25.f90 -O2 execution test FAIL: gfortran.dg/finalize_25.f90 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gfortran.dg/finalize_25.f90 -O3 -g execution test FAIL: gfortran.dg/finalize_25.f90 -Os execution test FAIL: gfortran.dg/no_arg_check_2.f90 -O scan-tree-dump-times original "sub_array_assumed \\\\(\\\\(struct t1.0:. .\\\\) parm" 1 WARNING: gfortran.dg/pdt_14.f03 -O2 execution test program timed out. FAIL: gfortran.dg/pdt_14.f03 -O2 execution test WARNING: gfortran.dg/pdt_14.f03 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test program timed out. FAIL: gfortran.dg/pdt_14.f03 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test WARNING: gfortran.dg/pdt_14.f03 -O3 -g execution test program timed out. FAIL: gfortran.dg/pdt_14.f03 -O3 -g execution test WARNING: gfortran.dg/pdt_14.f03 -Os execution test program timed out. FAIL: gfortran.dg/pdt_14.f03 -Os execution test FAIL: gfortran.dg/sizeof_4.f90 -O0 execution test FAIL: gfortran.dg/sizeof_4.f90 -O1 execution test FAIL: gfortran.dg/sizeof_4.f90 -O2 execution test FAIL: gfortran.dg/sizeof_4.f90 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gfortran.dg/sizeof_4.f90 -O3 -g execution test FAIL: gfortran.dg/sizeof_4.f90 -Os execution test With asumed_type_9.f90 we get: __final_test_T4 (struct array15_t4 & restrict array, integer(kind=8) byte_stride, logical(kind=1) fini_coarray) called as: struct array00_t1 decl_uidesc.19 .... __final_test_T4 (&desc.19, 24, 0); and we optimize out initializer of desc.19 since it is TBAA incompatible (so same problem as with assumed type but this time the consumer descriptor is not universal; just different). With finalize_25 I see: __final_gn_Sl (struct array15_sl & restrict array, integer(kind=8) byte_stride, logical(kind=1) fini_coarray) called as: struct array00_sl desc.20 ... __final_gn_Sl (&desc.20, 64, 0); With pdf14_f03 I get disambiguation ipa-modref: in main/8, call to push_8/6 does not clobber __vtab_link_module_Pdtlink_8._deallocate 14->13 so this seems different and I am not quite sure what is wrong here. FAIL: gfortran.dg/sizeof_4.f90 -O1 execution test actually goes away with reverting your patch. Honza > > Tobias > > gcc/fortran/ChangeLog: > > * trans-array.c (gfc_conv_expr_descriptor): > (gfc_conv_array_parameter): > * trans-array.h (gfc_conv_expr_descriptor): > > gcc/fortran/trans-array.c | 15 +++++++++------ > gcc/fortran/trans-array.h | 3 ++- > 2 files changed, 11 insertions(+), 7 deletions(-) > > diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c > index 6566c47d4ae..a5d1b477a0a 100644 > --- a/gcc/fortran/trans-array.c > +++ b/gcc/fortran/trans-array.c > @@ -7216,7 +7216,7 @@ walk_coarray (gfc_expr *e) > function call. */ > > void > -gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr) > +gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr, bool want_assumed_type) > { > gfc_ss *ss; > gfc_ss_type ss_type; > @@ -7611,7 +7611,9 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr) > else > { > /* Otherwise make a new one. */ > - if (expr->ts.type == BT_CHARACTER && expr->ts.deferred) > + if (want_assumed_type) > + parmtype = ptr_type_node; > + else if (expr->ts.type == BT_CHARACTER && expr->ts.deferred) > parmtype = gfc_typenode_for_spec (&expr->ts); > else > parmtype = gfc_get_element_type (TREE_TYPE (desc)); > @@ -7950,7 +7952,8 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, bool g77, > { > if (sym->attr.dummy || sym->attr.result) > { > - gfc_conv_expr_descriptor (se, expr); > + gfc_conv_expr_descriptor (se, expr, > + fsym && fsym->ts.type == BT_ASSUMED); > tmp = se->expr; > } > if (size) > @@ -8014,7 +8017,7 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, bool g77, > > if (no_pack || array_constructor || good_allocatable || ultimate_alloc_comp) > { > - gfc_conv_expr_descriptor (se, expr); > + gfc_conv_expr_descriptor (se, expr, fsym && fsym->ts.type == BT_ASSUMED); > /* Deallocate the allocatable components of structures that are > not variable. */ > if ((expr->ts.type == BT_DERIVED || expr->ts.type == BT_CLASS) > @@ -8037,7 +8040,7 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, bool g77, > if (this_array_result) > { > /* Result of the enclosing function. */ > - gfc_conv_expr_descriptor (se, expr); > + gfc_conv_expr_descriptor (se, expr, fsym && fsym->ts.type == BT_ASSUMED); > if (size) > array_parameter_size (se->expr, expr, size); > se->expr = gfc_build_addr_expr (NULL_TREE, se->expr); > @@ -8053,7 +8056,7 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, bool g77, > { > /* Every other type of array. */ > se->want_pointer = 1; > - gfc_conv_expr_descriptor (se, expr); > + gfc_conv_expr_descriptor (se, expr, fsym && fsym->ts.type == BT_ASSUMED); > > if (size) > array_parameter_size (build_fold_indirect_ref_loc (input_location, > diff --git a/gcc/fortran/trans-array.h b/gcc/fortran/trans-array.h > index e561605aaed..be3b1b79860 100644 > --- a/gcc/fortran/trans-array.h > +++ b/gcc/fortran/trans-array.h > @@ -143,7 +143,8 @@ void gfc_get_dataptr_offset (stmtblock_t*, tree, tree, tree, bool, gfc_expr*); > /* Obtain the span of an array. */ > tree gfc_get_array_span (tree, gfc_expr *); > /* Evaluate an array expression. */ > -void gfc_conv_expr_descriptor (gfc_se *, gfc_expr *); > +void gfc_conv_expr_descriptor (gfc_se *, gfc_expr *, > + bool want_assumed_type = false); > /* Convert an array for passing as an actual function parameter. */ > void gfc_conv_array_parameter (gfc_se *, gfc_expr *, bool, > const gfc_symbol *, const char *, tree *);