Hello Bernhard, On Fri, Feb 24, 2023 at 9:20 AM Bernhard Reutner-Fischer <rep.dot....@gmail.com> wrote:
> > > * decl.cc: Add EXT_ATTR_NOINLINE, EXT_ATTR_NORETURN, EXT_ATTR_WEAK. > > > * gfortran.h (ext_attr_id_t): Ditto. > > > > We had that discussion recently here.. > > Which of these are required to be recorded to the module and why, > > exactly? Please elaborate. > The aforementioned discussion was here: > https://gcc.gnu.org/pipermail/fortran/2022-November/058542.html > > So, again, please elaborate why you need to store each of NOINLINE, > NORETURN, WEAK in the module? 1. In .mod files technically only NORETURN needs to be stored for module contained procedures callsites. It should be handled the same as the DEPRECATED attribute. module foo !GCC$ ATTRIBUTES noreturn :: abort_msg contains subroutine abort_msg(cmsg) ! ... end subroutine) end module Otherwise there will be failure in already added test: FAIL: gfortran.dg/noreturn-1.f90 -O detect falling off end of noreturn (test for warnings, line 9) 2. The NOINLINE attribute can be excluded from on-disk .mod file until/if there would be added a way to inline say scalar functions that evaluate to constants at compile time when compiling with optimizations. 3. The WEAK attribute certainly needs to be excluded from on-disk generated .mod files, I do not see a legitimate use case where such information would be used in module imports. Except maybe for FL_SUBMODULE cases that I so far have not investigated how it interacts with FL_MODULE. My attempt to mask out NOINLINE/WEAK was with: diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc index 601497e0998..1789be88b73 100644 --- a/gcc/fortran/module.cc +++ b/gcc/fortran/module.cc @@ -2245,7 +2245,7 @@ static void mio_symbol_attribute (symbol_attribute *attr) { atom_type t; - unsigned ext_attr,extension_level; + unsigned ext_attr,extension_level,ext_mask; mio_lparen (); @@ -2255,7 +2255,12 @@ mio_symbol_attribute (symbol_attribute *attr) attr->if_source = MIO_NAME (ifsrc) (attr->if_source, ifsrc_types); attr->save = MIO_NAME (save_state) (attr->save, save_status); - ext_attr = attr->ext_attr; + /* Do not save EXT_ATTR_NOINLINE and EXT_ATTR_WEAK into .mod file. */ + ext_mask = (1 << EXT_ATTR_LAST) - 1; + ext_mask -= 1 << EXT_ATTR_NOINLINE; + ext_mask -= 1 << EXT_ATTR_WEAK; + + ext_attr = attr->ext_attr & ext_mask; mio_integer ((int *) &ext_attr); attr->ext_attr = ext_attr; And results in failures for testcases submitted for review in part2 and part3 patches: FAIL: gfortran.dg/noinline-2.f90 -O scan-tree-dump-times dom2 "foo \\\\(" 4 FAIL: gfortran.dg/weak-2.f90 -O scan-assembler weak[^ \\t]*[ \\t]_?__foo_MOD_abc I am not sure if this is a correct place to do such masking and/or why it results in these specific failures. Regards, Rimvydas