This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/47266] New: Optimization: Declare PRIVATE module procedures as "TREE_PUBLIC = 0" ("static function")
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 12 Jan 2011 09:20:27 +0000
- Subject: [Bug fortran/47266] New: Optimization: Declare PRIVATE module procedures as "TREE_PUBLIC = 0" ("static function")
- Auto-submitted: auto-generated
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