public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40973] Mark PRIVATE module functions as STATIC to faciliate optimization
[not found] <bug-40973-4@http.gcc.gnu.org/bugzilla/>
@ 2012-04-03 15:25 ` burnus at gcc dot gnu.org
2012-04-08 7:15 ` burnus at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-04-03 15:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40973
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-04-03 15:24:35 UTC ---
See also PR 52751 for module variables.
Draft patch:
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1842,7 +1857,8 @@ build_function_decl (gfc_symbol * sym, bool global)
DECL_EXTERNAL (fndecl) = 0;
if (!current_function_decl
- && !sym->attr.entry_master && !sym->attr.is_main_program)
+ && !sym->attr.entry_master && !sym->attr.is_main_program
+ && (sym->attr.access != ACCESS_PRIVATE || sym->binding_label))
TREE_PUBLIC (fndecl) = 1;
attributes = add_attributes_to_decl (attr, NULL_TREE);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/40973] Mark PRIVATE module functions as STATIC to faciliate optimization
[not found] <bug-40973-4@http.gcc.gnu.org/bugzilla/>
2012-04-03 15:25 ` [Bug fortran/40973] Mark PRIVATE module functions as STATIC to faciliate optimization burnus at gcc dot gnu.org
@ 2012-04-08 7:15 ` burnus at gcc dot gnu.org
2012-04-08 8:07 ` burnus at gcc dot gnu.org
2012-04-15 5:53 ` burnus at gcc dot gnu.org
3 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-04-08 7:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40973
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-04-08 07:15:12 UTC ---
Author: burnus
Date: Sun Apr 8 07:15:01 2012
New Revision: 186223
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186223
Log:
2012-04-08 Tobias Burnus <burnus@net-b.de>
PR fortran/52751
* trans-decl.c (gfc_finish_var_decl): Don't set TREE_PUBLIC
for PRIVATE module variables without C-binding label.
PR fortran/40973
* trans-decl.c (build_function_decl): Ditto for procedures.
2012-04-08 Tobias Burnus <burnus@net-b.de>
PR fortran/40973
PR fortran/52751
* gfortran.dg/public_private_module_2.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/public_private_module_2.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-decl.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/40973] Mark PRIVATE module functions as STATIC to faciliate optimization
[not found] <bug-40973-4@http.gcc.gnu.org/bugzilla/>
2012-04-03 15:25 ` [Bug fortran/40973] Mark PRIVATE module functions as STATIC to faciliate optimization burnus at gcc dot gnu.org
2012-04-08 7:15 ` burnus at gcc dot gnu.org
@ 2012-04-08 8:07 ` burnus at gcc dot gnu.org
2012-04-15 5:53 ` burnus at gcc dot gnu.org
3 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-04-08 8:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40973
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-04-08 08:07:27 UTC ---
FIXED on the 4.8 trunk.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/40973] Mark PRIVATE module functions as STATIC to faciliate optimization
[not found] <bug-40973-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2012-04-08 8:07 ` burnus at gcc dot gnu.org
@ 2012-04-15 5:53 ` burnus at gcc dot gnu.org
3 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-04-15 5:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40973
--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-04-15 05:52:58 UTC ---
Author: burnus
Date: Sun Apr 15 05:52:51 2012
New Revision: 186464
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186464
Log:
2012-04-14 Tobias Burnus <burnus@net-b.de>
PR fortran/52916
PR fortran/40973
* gfortran.h (symbol_attribute): Add public_used.
* interface.c (check_sym_interfaces, check_uop_interfaces,
gfc_check_interfaces): Set it.
* resolve.c (resolve_typebound_procedure): Ditto.
* trans-decl.c (build_function_decl): Use it.
2012-04-14 Tobias Burnus <burnus@net-b.de>
PR fortran/52916
PR fortran/40973
* gfortran.dg/public_private_module_3.f90: New.
* gfortran.dg/public_private_module_4.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/public_private_module_3.f90
trunk/gcc/testsuite/gfortran.dg/public_private_module_4.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/gfortran.h
trunk/gcc/fortran/interface.c
trunk/gcc/fortran/resolve.c
trunk/gcc/fortran/trans-decl.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/40973] Mark PRIVATE module functions as STATIC to faciliate optimization
2009-08-05 16:09 [Bug fortran/40973] New: " burnus at gcc dot gnu dot org
2009-12-04 23:28 ` [Bug fortran/40973] " dfranke at gcc dot gnu dot org
@ 2010-02-20 22:08 ` burnus at gcc dot gnu dot org
1 sibling, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-20 22:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from burnus at gcc dot gnu dot org 2010-02-20 22:08 -------
Marking it as STATIC will become difficult with SUBMODULES as one has several
.o files belonging to one common MODULE, i.e. the function shall be accessible
by all submodules, which are scattered over several .o files.
With -flto -fwhole-program it should be possible to optimize the function away
even without using STATIC.
(In reply to comment #1)
> How about this (somewhat constructed) example:
I fail to see why __m_MOD_two is needed - it is not called anywhere.
> ! interface module, file (a)
> MODULE M
> PRIVATE :: two
[...]
> integer FUNCTION two() [...]
> END MODULE
> ! implementation, file (b)
> SUBROUTINE one(a)
> USE M
> integer :: a
> a = two()
> END SUBROUTINE one
You are calling "two_" which is a REAL function and you are not calling an
INTEGER function and specifically you are not calling __m_MOD_two.
"two" is just an implicitly type external function.
> SUBROUTINE three(a)
> integer :: a
> a = two()
> END SUBROUTINE three
This one should be identical to "one".
> I often use modules simply to provide interfaces for subroutines implemented
> in other files and compiled into libraries
You should use ABSTRACT INTERFACE to provide interfaces...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40973
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/40973] Mark PRIVATE module functions as STATIC to faciliate optimization
2009-08-05 16:09 [Bug fortran/40973] New: " burnus at gcc dot gnu dot org
@ 2009-12-04 23:28 ` dfranke at gcc dot gnu dot org
2010-02-20 22:08 ` burnus at gcc dot gnu dot org
1 sibling, 0 replies; 6+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2009-12-04 23:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from dfranke at gcc dot gnu dot org 2009-12-04 23:28 -------
How about this (somewhat constructed) example:
! interface module, file (a)
MODULE M
PRIVATE :: two
CONTAINS
SUBROUTINE one(a)
integer :: a
END SUBROUTINE one
integer FUNCTION two()
END FUNCTION two
END MODULE
! implementation, file (b)
SUBROUTINE one(a)
USE M
integer :: a
a = two()
END SUBROUTINE one
integer FUNCTION two()
two = 42
END FUNCTION two
! another user of the function, without using the interface module, file (c)
SUBROUTINE three(a)
integer :: a
a = two()
END SUBROUTINE three
I often use modules simply to provide interfaces for subroutines implemented in
other files and compiled into libraries, then distributing the interface
modules together with the library to avoid issues with .mod files of varying
compiler versions.
--
dfranke at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dfranke at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40973
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-04-15 5:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-40973-4@http.gcc.gnu.org/bugzilla/>
2012-04-03 15:25 ` [Bug fortran/40973] Mark PRIVATE module functions as STATIC to faciliate optimization burnus at gcc dot gnu.org
2012-04-08 7:15 ` burnus at gcc dot gnu.org
2012-04-08 8:07 ` burnus at gcc dot gnu.org
2012-04-15 5:53 ` burnus at gcc dot gnu.org
2009-08-05 16:09 [Bug fortran/40973] New: " burnus at gcc dot gnu dot org
2009-12-04 23:28 ` [Bug fortran/40973] " dfranke at gcc dot gnu dot org
2010-02-20 22:08 ` burnus at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).