[Bug fortran/47266] New: Optimization: Declare PRIVATE module procedures as "TREE_PUBLIC = 0" ("static function")
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jan 12 09:40:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47266
Summary: Optimization: Declare PRIVATE module procedures as
"TREE_PUBLIC = 0" ("static function")
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
Found when thinking about PR 47260.
PRIVATE module procedures are by construction not accessible outside the
translation unit. Well, one can then simply mark them as "static" (in the C
sense) by not setting TREE_PUBLIC to 1.
For procedures one currently calls gfc_create_function_decl,
which calls build_function_decl. That function contains:
if (!current_function_decl
&& !sym->attr.entry_master && !sym->attr.is_main_program)
TREE_PUBLIC (fndecl) = 1;
Thus, adding "&& !sym->attr.access == ACCESS_PRIVATE" should be sufficient.
Test case
- Expected: With "-O2 -c", "nm" only prints "__m_MOD_pub"
- Current result, "nm" shows:
000000000000001e T __m_MOD_priv
0000000000000000 T __m_MOD_pub
module m
implicit none
private :: priv
public :: pub
contains
integer function priv()
priv = 44
end function priv
subroutine pub(a)
integer :: a
a = priv()
end subroutine pub
end module m
More information about the Gcc-bugs
mailing list