Re: [Ping, Patch, www-docs, Fortran, Coarray-ABI] Announce coarray-ABI changes in gfortran-15
On 3/6/25 10:02 AM, Steve Kargl wrote: Andre, Here's a bit of wordsmith. I removed the abbreviation "Esp." I'm not sure if there is additional markup needed; especially, with the "-fcoarray=single" I inserted. Coarray support has been reworked to allow access to components in derived types that have not been compiled with coarray support enabled; especially, when the derived type is in a binary only module. This has changed the ABI and may lead to link-time errors with libraries compiled with a previous GCC version and the -fcoarray=single option. If this option has been used, it is recommended to recompile the libraries. The OpenCoarrays library is not affected, because it provides support backwards compatibility with the older ABI. I'm not sure how to test the change. OK to commit with or without my suggested change. For www-docs there is an html check script provided. You can also review by looking with a web browser. For texi files, if make info succeeds and review the resulting info files installed in the usr/share if I recall correctly. Jerry
Re: [Ping, Patch, www-docs, Fortran, Coarray-ABI] Announce coarray-ABI changes in gfortran-15
PING! On Thu, 20 Feb 2025 10:54:30 +0100 Andre Vehreschild wrote: > Hi all, > > attached patch makes an attempt to announce the ABI-changes in the coarrays > library. Me being German always has difficulties to find a proper wording. So > please propose improvements. > > Stupid question: How to I test this? The change looks good in my browser. Is > there a style checker, I don't see? > > Regards, > Ande > -- > Andre Vehreschild * Email: vehre ad gmx dot de -- Andre Vehreschild * Email: vehre ad gmx dot de From 8b1ba25dd27c89dc6ff860835431e09f3895a4e1 Mon Sep 17 00:00:00 2001 From: Andre Vehreschild Date: Thu, 20 Feb 2025 10:47:22 +0100 Subject: [PATCH] gcc-15/changes: Document coarray changes. ABI of coarrays has changed. Document possible linker errors for caf_single. --- htdocs/gcc-15/changes.html | 6 ++ 1 file changed, 6 insertions(+) diff --git a/htdocs/gcc-15/changes.html b/htdocs/gcc-15/changes.html index 853fad03..ea1e7553 100644 --- a/htdocs/gcc-15/changes.html +++ b/htdocs/gcc-15/changes.html @@ -436,6 +436,12 @@ asm (".text; %cc0: mov %cc2, %%r0; .previous;" incompatible with the module format generated by GCC 8 - 14, but GCC 15 can for compatibility still read GCC 8 - 14 created module files. + Coarray support has been reworked to allow access to data in derived types + that have not been compiled with coarray support enabled. Esp. when the + derived type is in a binary only module. This may lead to linking errors + with the provided caf_single-libraries of previous GCC versions. It is + recommended to only use the newest version of caf_single. The OpenCoarrays + library is not affected and provides all ABIs. -- 2.48.1
Re: [PATCH] Fortran: improve checking of substring bounds [PR119118]
On Thu, Mar 06, 2025 at 10:49:08PM +0100, Harald Anlauf wrote: > > Thanks for the speedy review! > It was a bit easier than normal. After I submitted the PR, I started to poke around in fortran/resolve.cc to see if I could deal with the issue. I saw that you grab the PR last night, and left you to work your magic. -- Steve
Re: [PATCH] Fortran: improve checking of substring bounds [PR119118]
On Thu, Mar 06, 2025 at 10:04:08PM +0100, Harald Anlauf wrote: > > this patch fixes an interesting regression that prevented substring > bounds checks from being generated if the substring start was not a > variable, but rather a constant or an expression. > > The fix I chose turned out to be a little larger than I anticipated: > handling the case of an expression being used needs scanning for > implied-do indices. See attached patch for details. > > Regtested on x86_64-pc-linux-gnu. OK for mainline? > Bene quidem! Thanks for expanded the testcases to include implied-do. One nit below. OK to comment. > + > +/* Traverse expr, checking all EXPR_VARIABLE symbols for their > + implied_index attribute. Return true if any variable may be > + being used as an implied-do index. Its safe to pessimistically The word "being" can be deleted. > + return true, and assume a dependency. */ -- steve
Re: [Ping, Patch, www-docs, Fortran, Coarray-ABI] Announce coarray-ABI changes in gfortran-15
Andre, Here's a bit of wordsmith. I removed the abbreviation "Esp." I'm not sure if there is additional markup needed; especially, with the "-fcoarray=single" I inserted. Coarray support has been reworked to allow access to components in derived types that have not been compiled with coarray support enabled; especially, when the derived type is in a binary only module. This has changed the ABI and may lead to link-time errors with libraries compiled with a previous GCC version and the -fcoarray=single option. If this option has been used, it is recommended to recompile the libraries. The OpenCoarrays library is not affected, because it provides support backwards compatibility with the older ABI. I'm not sure how to test the change. OK to commit with or without my suggested change. -- steve On Thu, Mar 06, 2025 at 03:42:43PM +0100, Andre Vehreschild wrote: > PING! > > On Thu, 20 Feb 2025 10:54:30 +0100 > Andre Vehreschild wrote: > > > Hi all, > > > > attached patch makes an attempt to announce the ABI-changes in the coarrays > > library. Me being German always has difficulties to find a proper wording. > > So > > please propose improvements. > > > > Stupid question: How to I test this? The change looks good in my browser. Is > > there a style checker, I don't see? > > > > Regards, > > Ande > > -- > > Andre Vehreschild * Email: vehre ad gmx dot de > > > -- > Andre Vehreschild * Email: vehre ad gmx dot de > From 8b1ba25dd27c89dc6ff860835431e09f3895a4e1 Mon Sep 17 00:00:00 2001 > From: Andre Vehreschild > Date: Thu, 20 Feb 2025 10:47:22 +0100 > Subject: [PATCH] gcc-15/changes: Document coarray changes. > > ABI of coarrays has changed. Document possible linker errors for > caf_single. > --- > htdocs/gcc-15/changes.html | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/htdocs/gcc-15/changes.html b/htdocs/gcc-15/changes.html > index 853fad03..ea1e7553 100644 > --- a/htdocs/gcc-15/changes.html > +++ b/htdocs/gcc-15/changes.html > @@ -436,6 +436,12 @@ asm (".text; %cc0: mov %cc2, %%r0; .previous;" >incompatible with the module format generated by GCC 8 - 14, but GCC >15 can for compatibility still read GCC 8 - 14 created module >files. > + Coarray support has been reworked to allow access to data in derived > types > + that have not been compiled with coarray support enabled. Esp. when > the > + derived type is in a binary only module. This may lead to linking > errors > + with the provided caf_single-libraries of previous GCC versions. It is > + recommended to only use the newest version of caf_single. The > OpenCoarrays > + library is not affected and provides all ABIs. > > > > -- > 2.48.1 > -- Steve
[PATCH] Fortran: improve checking of substring bounds [PR119118]
Dear all, this patch fixes an interesting regression that prevented substring bounds checks from being generated if the substring start was not a variable, but rather a constant or an expression. The fix I chose turned out to be a little larger than I anticipated: handling the case of an expression being used needs scanning for implied-do indices. See attached patch for details. Regtested on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald From c100ca04bb5b540732837d92f67529212a7c0899 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 6 Mar 2025 21:45:42 +0100 Subject: [PATCH] Fortran: improve checking of substring bounds [PR119118] After the fix for pr98490 no substring bounds check was generated if the substring start was not a variable. While the purpose of that fix was to suppress a premature check before implied-do indices were substituted, this prevented a check if the substring start was an expression or a constant. A better solution is to defer the check until implied-do indices have been substituted in the start and end expressions. PR fortran/119118 gcc/fortran/ChangeLog: * dependency.cc (gfc_contains_implied_index_p): Helper function to determine if an expression has a dependence on an implied-do index. * dependency.h (gfc_contains_implied_index_p): Add prototype. * trans-expr.cc (gfc_conv_substring): Adjust logic to not generate substring bounds checks before implied-do indices have been substituted. gcc/testsuite/ChangeLog: * gfortran.dg/bounds_check_23.f90: Generalize test. * gfortran.dg/bounds_check_26.f90: New test. --- gcc/fortran/dependency.cc | 81 +++ gcc/fortran/dependency.h | 1 + gcc/fortran/trans-expr.cc | 4 +- gcc/testsuite/gfortran.dg/bounds_check_23.f90 | 18 - gcc/testsuite/gfortran.dg/bounds_check_26.f90 | 24 ++ 5 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/bounds_check_26.f90 diff --git a/gcc/fortran/dependency.cc b/gcc/fortran/dependency.cc index 6b3affa6057..9f1ff574545 100644 --- a/gcc/fortran/dependency.cc +++ b/gcc/fortran/dependency.cc @@ -1888,6 +1888,87 @@ contains_forall_index_p (gfc_expr *expr) return false; } + +/* Traverse expr, checking all EXPR_VARIABLE symbols for their + implied_index attribute. Return true if any variable may be + being used as an implied-do index. Its safe to pessimistically + return true, and assume a dependency. */ + +bool +gfc_contains_implied_index_p (gfc_expr *expr) +{ + gfc_actual_arglist *arg; + gfc_constructor *c; + gfc_ref *ref; + int i; + + if (!expr) +return false; + + switch (expr->expr_type) +{ +case EXPR_VARIABLE: + if (expr->symtree->n.sym->attr.implied_index) + return true; + break; + +case EXPR_OP: + if (gfc_contains_implied_index_p (expr->value.op.op1) + || gfc_contains_implied_index_p (expr->value.op.op2)) + return true; + break; + +case EXPR_FUNCTION: + for (arg = expr->value.function.actual; arg; arg = arg->next) + if (gfc_contains_implied_index_p (arg->expr)) + return true; + break; + +case EXPR_CONSTANT: +case EXPR_NULL: +case EXPR_SUBSTRING: + break; + +case EXPR_STRUCTURE: +case EXPR_ARRAY: + for (c = gfc_constructor_first (expr->value.constructor); + c; gfc_constructor_next (c)) + if (gfc_contains_implied_index_p (c->expr)) + return true; + break; + +default: + gcc_unreachable (); +} + + for (ref = expr->ref; ref; ref = ref->next) +switch (ref->type) + { + case REF_ARRAY: + for (i = 0; i < ref->u.ar.dimen; i++) + if (gfc_contains_implied_index_p (ref->u.ar.start[i]) + || gfc_contains_implied_index_p (ref->u.ar.end[i]) + || gfc_contains_implied_index_p (ref->u.ar.stride[i])) + return true; + break; + + case REF_COMPONENT: + break; + + case REF_SUBSTRING: + if (gfc_contains_implied_index_p (ref->u.ss.start) + || gfc_contains_implied_index_p (ref->u.ss.end)) + return true; + break; + + default: + gcc_unreachable (); + } + + return false; +} + + /* Determines overlapping for two single element array references. */ static gfc_dependency diff --git a/gcc/fortran/dependency.h b/gcc/fortran/dependency.h index 3f81d406082..2fc2e567a4c 100644 --- a/gcc/fortran/dependency.h +++ b/gcc/fortran/dependency.h @@ -41,6 +41,7 @@ bool gfc_dep_resolver (gfc_ref *, gfc_ref *, gfc_reverse *, bool identical = false); bool gfc_are_equivalenced_arrays (gfc_expr *, gfc_expr *); bool gfc_omp_expr_prefix_same (gfc_expr *, gfc_expr *); +bool gfc_contains_implied_index_p (gfc_expr *); gfc_expr * gfc_discard_nops (gfc_expr *); diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index fbe7333fd71..d965539f11e 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -2814,8 +2814,8 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind