This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Debugging and PR87352
- From: Jeremy Sanders <jeremy at jeremysanders dot net>
- To: fortran at gcc dot gnu dot org
- Date: Sun, 24 Mar 2019 18:35:59 +0100
- Subject: Debugging and PR87352
Dear developers
As I've hit a number of gfortran bugs (PR87542 and probably PR56471 when
I tried to workaround it), I thought I would dig into the source code of
gfortran. It's quite difficult to debug given the complex structures
which are passed around. Are there any functions to print some of the
gfc_ structures, e.g. gfc_symbol, gfc_expr, gfc_namespace, gfc_code...?
For PR87542, if there is a declaration like this
module testmodule
use iso_fortran_env
implicit none
public
type :: evtlist_type
real (kind=real64), allocatable, dimension(:) :: p1
real (kind=real64), allocatable, dimension(:) :: p2
! add more entries here to observe N**2 behaviour
end type evtlist_type
type :: evtlistlist_type
type(evtlist_type) :: evtlist(1:1)
end type evtlistlist_type
contains
end module testmodule
gfortran makes ~N**2 invocations of structure_alloc_comps, where N here
is 2. If you add more of the allocatable arrays to evtlist_type then N
increases. This leads to huge code and compile time bloat (scaling as
N**2), where each member is checked whether it is allocated and then
freed if it is not N times.
I'm guessing this is something to do with the logic in
generate_finalization_wrapper and finalize_component. If I comment out
the loop part of finalize_component, then the excess finalizers are not
added. Unfortunately my understanding of the code isn't complete yet -
hence my wondering whether it's possible to dump out some of the gfc
data structures to the screen.
Thanks
Jeremy Sanders
(please CC me as I'm not on the list)