re PR fortran/87352 (Large stack usage with new gfortran)

2019-04-14  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/87352
	Backport from trunk
	* gfortran.h (gfc_component): Add finalized field.
	* class.c (finalize_component): If the component is already
	finalized, return early.  Set component->finalized on exit.

2019-04-14  Thomas Koenig  <tkoenig@gcc.gnu.org>

	Backport from trunk
	PR fortran/87352
	* gfortran.dg/finalize_28.f90: Adjust count of __builtin_free.
	* gfortran.dg/finalize_34.f90: New test.

From-SVN: r270352
This commit is contained in:
Thomas Koenig 2019-04-14 12:27:44 +00:00
parent a6ce895f7e
commit f537563bd4
6 changed files with 53 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2019-04-14 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/87352
Backport from trunk
* gfortran.h (gfc_component): Add finalized field.
* class.c (finalize_component): If the component is already
finalized, return early. Set component->finalized on exit.
2019-04-10 Harald Anlauf <anlauf@gmx.de>
Backport from trunk

View File

@ -899,6 +899,9 @@ finalize_component (gfc_expr *expr, gfc_symbol *derived, gfc_component *comp,
if (!comp_is_finalizable (comp))
return;
if (comp->finalized)
return;
e = gfc_copy_expr (expr);
if (!e->ref)
e->ref = ref = gfc_get_ref ();
@ -1026,6 +1029,7 @@ finalize_component (gfc_expr *expr, gfc_symbol *derived, gfc_component *comp,
sub_ns);
gfc_free_expr (e);
}
comp->finalized = true;
}

View File

@ -1058,6 +1058,7 @@ typedef struct gfc_component
struct gfc_typebound_proc *tb;
/* When allocatable/pointer and in a coarray the associated token. */
tree caf_token;
bool finalized;
}
gfc_component;

View File

@ -1,3 +1,17 @@
2019-04-14 Thomas Koenig <tkoenig@gcc.gnu.org>
Backport from trunk
PR fortran/87352
* gfortran.dg/finalize_28.f90: Adjust count of __builtin_free.
* gfortran.dg/finalize_34.f90: New test.
2019-04-14 Thomas Koenig <tkoenig@gcc.gnu.org>
Backport from trunk
PR fortran/87352
* gfortran.dg/finalize_28.f90: Adjust count of __builtin_free.
* gfortran.dg/finalize_34.f90: New test.
2019-04-11 Martin Liska <mliska@suse.cz>
Backport from mainline

View File

@ -21,4 +21,4 @@ contains
integer, intent(out) :: edges(:,:)
end subroutine coo_dump_edges
end module coo_graphs
! { dg-final { scan-tree-dump-times "__builtin_free" 6 "original" } }
! { dg-final { scan-tree-dump-times "__builtin_free" 5 "original" } }

View File

@ -0,0 +1,25 @@
! { dg-do compile }
! { dg-additional-options "-fdump-tree-original" }
! PR 87352 - this used to cause an excessive number of deallocations.
module testmodule
implicit none
public
type :: evtlist_type
real, allocatable, dimension(:) :: p1
real, allocatable, dimension(:) :: p2
real, allocatable, dimension(:) :: p3
real, allocatable, dimension(:) :: p4
end type evtlist_type
type :: evtlistlist_type
type(evtlist_type) :: evtlist(1:1)
end type evtlistlist_type
end module testmodule
program main
use testmodule
type(evtlist_type), dimension(10) :: a
end program main
! { dg-final { scan-tree-dump-times "__builtin_free" 8 "original" } }