public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/50919] New: [OOP] Don't use vtable for NON_OVERRIDABLE TBP
@ 2011-10-30 10:09 burnus at gcc dot gnu.org
2011-10-31 12:08 ` [Bug fortran/50919] " janus at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-10-30 10:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50919
Bug #: 50919
Summary: [OOP] Don't use vtable for NON_OVERRIDABLE TBP
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
CC: janus@gcc.gnu.org
Current, gfortran uses always a vtable for type-bound procedures. However, a
vtable only makes sense if the type-bound procedure can be overridden (C++: if
it is "virtual").
Expected:
a) gfortran call the procedure directly, which allows for inlining and avoids
the pointer dereference.
b) When the ABI is changed, the procedure is no longer added to the vtable.
Hence, it should be added as item to
http://gcc.gnu.org/wiki/LibgfortranAbiCleanup
Test case. The dump shows the following rather than a simple "test ()":
callit (struct __class_m_T & restrict x)
{
x->_vptr->test ();
module m
type t
contains
procedure, nopass, NON_OVERRIDABLE :: test
end type t
contains
subroutine test()
print *, "t's test"
end subroutine test
subroutine callit(x)
class(t) :: x
call x%test()
end subroutine
end module m
tob@archimedes:/dev/shm> less poly.f90.*
tob@archimedes:/dev/shm> cat poly.f90
module m
type t
contains
procedure, nopass, NON_OVERRIDABLE :: test
end type t
contains
subroutine test()
print *, "t's test"
end subroutine test
subroutine callit(x)
class(t) :: x
call x%test()
end subroutine
end module m
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/50919] [OOP] Don't use vtable for NON_OVERRIDABLE TBP
2011-10-30 10:09 [Bug fortran/50919] New: [OOP] Don't use vtable for NON_OVERRIDABLE TBP burnus at gcc dot gnu.org
@ 2011-10-31 12:08 ` janus at gcc dot gnu.org
2011-10-31 12:31 ` janus at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: janus at gcc dot gnu.org @ 2011-10-31 12:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50919
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011-10-31
Ever Confirmed|0 |1
--- Comment #1 from janus at gcc dot gnu.org 2011-10-31 12:08:31 UTC ---
(In reply to comment #0)
> Expected:
> a) gfortran call the procedure directly, which allows for inlining and avoids
> the pointer dereference.
Good point. I hadn't thought of that ...
> Test case. The dump shows the following rather than a simple "test ()":
Here is an extended test case involving a type-bound subroutine and a
type-bound function (both of which have to be fixed):
module m
type t
contains
procedure, nopass, NON_OVERRIDABLE :: testsub
procedure, nopass, NON_OVERRIDABLE :: testfun
end type t
contains
subroutine testsub()
print *, "t's test"
end subroutine
integer function testfun()
testfun = 1
end function
end module m
use m
class(t), allocatable :: x
allocate(x)
call x%testsub()
print *,x%testfun()
end
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/50919] [OOP] Don't use vtable for NON_OVERRIDABLE TBP
2011-10-30 10:09 [Bug fortran/50919] New: [OOP] Don't use vtable for NON_OVERRIDABLE TBP burnus at gcc dot gnu.org
2011-10-31 12:08 ` [Bug fortran/50919] " janus at gcc dot gnu.org
@ 2011-10-31 12:31 ` janus at gcc dot gnu.org
2011-10-31 13:56 ` janus at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: janus at gcc dot gnu.org @ 2011-10-31 12:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50919
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |janus at gcc dot gnu.org
|gnu.org |
--- Comment #2 from janus at gcc dot gnu.org 2011-10-31 12:31:03 UTC ---
Created attachment 25672
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25672
patch
Here is a patch, which does two things:
1) The resolve.c part prevents the conversion to a PPC call (for functions and
subroutines).
2) The class.c parts prevents adding the non-overridable TBP to the vtable.
The second one breaks the ABI, while the first one does not. So, should I start
by committing the first part only, and waiting with the second one for the ABI
cleanup?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/50919] [OOP] Don't use vtable for NON_OVERRIDABLE TBP
2011-10-30 10:09 [Bug fortran/50919] New: [OOP] Don't use vtable for NON_OVERRIDABLE TBP burnus at gcc dot gnu.org
2011-10-31 12:08 ` [Bug fortran/50919] " janus at gcc dot gnu.org
2011-10-31 12:31 ` janus at gcc dot gnu.org
@ 2011-10-31 13:56 ` janus at gcc dot gnu.org
2011-10-31 14:42 ` burnus at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: janus at gcc dot gnu.org @ 2011-10-31 13:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50919
--- Comment #3 from janus at gcc dot gnu.org 2011-10-31 13:55:55 UTC ---
(In reply to comment #2)
> Created attachment 25672 [details]
> patch
... regtests cleanly!
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/50919] [OOP] Don't use vtable for NON_OVERRIDABLE TBP
2011-10-30 10:09 [Bug fortran/50919] New: [OOP] Don't use vtable for NON_OVERRIDABLE TBP burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2011-10-31 13:56 ` janus at gcc dot gnu.org
@ 2011-10-31 14:42 ` burnus at gcc dot gnu.org
2011-11-07 18:46 ` janus at gcc dot gnu.org
2011-11-07 19:14 ` janus at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-10-31 14:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50919
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-10-31 14:41:19 UTC ---
(In reply to comment #2)
> Created attachment 25672 [details]
> patch
Thanks for the patch!
> The second one breaks the ABI, while the first one does not. So, should I start
> by committing the first part only, and waiting with the second one for the ABI
> cleanup?
I think that's sensible: Submitting/committing the first one. And for the
second part: Add a link to this PR at
http://gcc.gnu.org/wiki/LibgfortranAbiCleanup
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/50919] [OOP] Don't use vtable for NON_OVERRIDABLE TBP
2011-10-30 10:09 [Bug fortran/50919] New: [OOP] Don't use vtable for NON_OVERRIDABLE TBP burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2011-10-31 14:42 ` burnus at gcc dot gnu.org
@ 2011-11-07 18:46 ` janus at gcc dot gnu.org
2011-11-07 19:14 ` janus at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: janus at gcc dot gnu.org @ 2011-11-07 18:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50919
--- Comment #5 from janus at gcc dot gnu.org 2011-11-07 18:41:16 UTC ---
Author: janus
Date: Mon Nov 7 18:41:12 2011
New Revision: 181107
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181107
Log:
2011-11-07 Janus Weil <janus@gcc.gnu.org>
PR fortran/50919
* class.c (add_proc_comp): Don't add non-overridable procedures to the
vtable.
* resolve.c (resolve_typebound_function,resolve_typebound_subroutine):
Don't generate a dynamic _vptr call for non-overridable procedures.
2011-11-07 Janus Weil <janus@gcc.gnu.org>
PR fortran/50919
* gfortran.dg/typebound_call_21.f03: New.
Added:
trunk/gcc/testsuite/gfortran.dg/typebound_call_21.f03
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/class.c
trunk/gcc/fortran/resolve.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/50919] [OOP] Don't use vtable for NON_OVERRIDABLE TBP
2011-10-30 10:09 [Bug fortran/50919] New: [OOP] Don't use vtable for NON_OVERRIDABLE TBP burnus at gcc dot gnu.org
` (4 preceding siblings ...)
2011-11-07 18:46 ` janus at gcc dot gnu.org
@ 2011-11-07 19:14 ` janus at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: janus at gcc dot gnu.org @ 2011-11-07 19:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50919
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #6 from janus at gcc dot gnu.org 2011-11-07 18:46:27 UTC ---
Fixed with r181107 (including both parts of the patch in comment 2). Closing.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-11-07 18:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-30 10:09 [Bug fortran/50919] New: [OOP] Don't use vtable for NON_OVERRIDABLE TBP burnus at gcc dot gnu.org
2011-10-31 12:08 ` [Bug fortran/50919] " janus at gcc dot gnu.org
2011-10-31 12:31 ` janus at gcc dot gnu.org
2011-10-31 13:56 ` janus at gcc dot gnu.org
2011-10-31 14:42 ` burnus at gcc dot gnu.org
2011-11-07 18:46 ` janus at gcc dot gnu.org
2011-11-07 19:14 ` janus at gcc dot gnu.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).