diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-01-10 10:28:18 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-01-10 10:28:18 +0100 |
commit | f5e488c0ee663c2355e6d712ffc15da215d9cd96 (patch) | |
tree | acced26789555bf44b37f4675b6794bff0893e63 /gcc | |
parent | bd28244ec92b9aac082f822987818ff1e11b67fd (diff) | |
download | gcc-f5e488c0ee663c2355e6d712ffc15da215d9cd96.zip gcc-f5e488c0ee663c2355e6d712ffc15da215d9cd96.tar.gz gcc-f5e488c0ee663c2355e6d712ffc15da215d9cd96.tar.bz2 |
fortran: use_iso_fortran_env_module tweaks [PR118337]
This patch adds a comment to explain why we initialize the non-constant
elts of symbol array separately and checking assert to verify that separate
initialization bumps the iterator for each macro.
2025-01-10 Jakub Jelinek <jakub@redhat.com>
PR fortran/118337
* module.cc (use_iso_fortran_env_module): Add a comment explaining
the optimization performed. Add gcc_checking_assert that i was
incremented for all the elements. Formatting fix.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/module.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc index 63d0cdb..490eaa9 100644 --- a/gcc/fortran/module.cc +++ b/gcc/fortran/module.cc @@ -7122,6 +7122,13 @@ use_iso_fortran_env_module (void) #include "iso-fortran-env.def" { ISOFORTRANENV_INVALID, NULL, -1234, 0 } }; + /* We could have used c in the NAMED_{,U}INTCST macros + instead of 0, but then current g++ expands the initialization + as clearing the whole object followed by explicit stores of + all the non-zero elements (over 150), while by using 0s for + the non-constant initializers and initializing them afterwards + g++ will often copy everything from .rodata and then only override + over 30 non-constant ones. */ i = 0; #define NAMED_INTCST(a,b,c,d) symbol[i++].value = c; #define NAMED_UINTCST(a,b,c,d) symbol[i++].value = c; @@ -7130,6 +7137,7 @@ use_iso_fortran_env_module (void) #define NAMED_FUNCTION(a,b,c,d) i++; #define NAMED_SUBROUTINE(a,b,c,d) i++; #include "iso-fortran-env.def" + gcc_checking_assert (i == (int) ARRAY_SIZE (symbol) - 1); /* Generate the symbol for the module itself. */ mod_symtree = gfc_find_symtree (gfc_current_ns->sym_root, mod); @@ -7288,12 +7296,11 @@ use_iso_fortran_env_module (void) break; #define NAMED_FUNCTION(a,b,c,d) \ - case a: + case a: #include "iso-fortran-env.def" - create_intrinsic_function (symbol[i].name, symbol[i].id, mod, - INTMOD_ISO_FORTRAN_ENV, false, - NULL); - break; + create_intrinsic_function (symbol[i].name, symbol[i].id, mod, + INTMOD_ISO_FORTRAN_ENV, false, NULL); + break; default: gcc_unreachable (); |