Re: *PING* / Re: [Patch, Fortran] Finalize nonallocatables with INTENT(out)
Tobias Burnus wrote: Dominique Dhumieres wrote: I have tried to weaken the test by not using any target and using a regexp of the kind "(int|long)", but I did not succeeded. Ups, I missed that Dominique's and Andreas' 32bit dumps are different ("unsigned int" vs. "character(kind=4)"). Thus, the new pattern accepts either version. Committed as 26. Tobias Index: gcc/testsuite/ChangeLog === --- gcc/testsuite/ChangeLog (Revision 23) +++ gcc/testsuite/ChangeLog (Arbeitskopie) @@ -1,7 +1,11 @@ 2013-06-12 Tobias Burnus + + * gfortran.dg/finalize_10.f90: Update scan-tree-dump. + +2013-06-12 Tobias Burnus Dominique d'Humieres - * gfortran.dg/finalize_10.f90: Update dg-dump. + * gfortran.dg/finalize_10.f90: Update scan-tree-dump. 2013-06-12 Jakub Jelinek Index: gcc/testsuite/gfortran.dg/finalize_10.f90 === --- gcc/testsuite/gfortran.dg/finalize_10.f90 (Revision 23) +++ gcc/testsuite/gfortran.dg/finalize_10.f90 (Arbeitskopie) @@ -26,7 +26,7 @@ ! Finalize CLASS + set default init ! { dg-final { scan-tree-dump-times "y->_vptr->_final \\(&desc.\[0-9\]+, y->_vptr->_size, 0\\);" 1 "original" } } -! { dg-final { scan-tree-dump "__builtin_memcpy \\(\\(void .\\) y->_data, \\(void .\\) y->_vptr->_def_init, \\(unsigned (long|int)\\) y->_vptr->_size\\);" "original" } } +! { dg-final { scan-tree-dump "__builtin_memcpy \\(\\(void .\\) y->_data, \\(void .\\) y->_vptr->_def_init, \\((unsigned long|unsigned int|character\\(kind=4\\))\\) y->_vptr->_size\\);" "original" } } ! { dg-final { scan-tree-dump-times "x->_vptr->_final \\(&x->_data, x->_vptr->_size, 0\\);" 1 "original" } } ! { dg-final { scan-tree-dump-times "x->_vptr->_copy \\(x->_vptr->_def_init, &x->_data\\);" 1 "original" } }
Re: *PING* / Re: [Patch, Fortran] Finalize nonallocatables with INTENT(out)
Thanks Dominique and Andreas for reporting this issue. Dominique Dhumieres wrote: The test gfortran.dg/finalize_10.f90 fails in 32 bit mode [...] The following patch fixes it [...] I have tried to weaken the test by not using any target and using a regexp of the kind "(int|long)", but I did not succeeded. Seemingly, dg-tree-dump-times does not work with regular expressions. I have replaces it by dg-tree-dump + regular expression. Committed as 23. Tobias Index: gcc/testsuite/ChangeLog === --- gcc/testsuite/ChangeLog (Revision 22) +++ gcc/testsuite/ChangeLog (Arbeitskopie) @@ -1,3 +1,8 @@ +2013-06-12 Tobias Burnus + Dominique d'Humieres + + * gfortran.dg/finalize_10.f90: Update dg-dump. + 2013-06-12 Jakub Jelinek PR target/56564 Index: gcc/testsuite/gfortran.dg/finalize_10.f90 === --- gcc/testsuite/gfortran.dg/finalize_10.f90 (Revision 22) +++ gcc/testsuite/gfortran.dg/finalize_10.f90 (Arbeitskopie) @@ -26,7 +26,7 @@ ! Finalize CLASS + set default init ! { dg-final { scan-tree-dump-times "y->_vptr->_final \\(&desc.\[0-9\]+, y->_vptr->_size, 0\\);" 1 "original" } } -! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(\\(void .\\) y->_data, \\(void .\\) y->_vptr->_def_init, \\(unsigned long\\) y->_vptr->_size\\);" 1 "original" } } +! { dg-final { scan-tree-dump "__builtin_memcpy \\(\\(void .\\) y->_data, \\(void .\\) y->_vptr->_def_init, \\(unsigned (long|int)\\) y->_vptr->_size\\);" "original" } } ! { dg-final { scan-tree-dump-times "x->_vptr->_final \\(&x->_data, x->_vptr->_size, 0\\);" 1 "original" } } ! { dg-final { scan-tree-dump-times "x->_vptr->_copy \\(x->_vptr->_def_init, &x->_data\\);" 1 "original" } }
Re: *PING* / Re: [Patch, Fortran] Finalize nonallocatables with INTENT(out)
Tobias Burnus writes: > --- /dev/null 2013-06-06 09:52:08.544104880 +0200 > +++ gcc/gcc/testsuite/gfortran.dg/finalize_10.f90 2013-06-03 > 12:32:38.763008261 +0200 > @@ -0,0 +1,39 @@ > +! { dg-do compile } > +! { dg-options "-fdump-tree-original" } > +! > +! PR fortran/37336 > +! > +! Finalize nonallocatable INTENT(OUT) > +! > +module m > + type t > + end type t > + type t2 > + contains > +final :: fini > + end type t2 > +contains > + elemental subroutine fini(var) > +type(t2), intent(inout) :: var > + end subroutine fini > +end module m > + > +subroutine foo(x,y,aa,bb) > + use m > + class(t), intent(out) :: x(:),y > + type(t2), intent(out) :: aa(:),bb > +end subroutine foo > + > +! Finalize CLASS + set default init > +! { dg-final { scan-tree-dump-times "y->_vptr->_final \\(&desc.\[0-9\]+, > y->_vptr->_size, 0\\);" 1 "original" } } > +! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(\\(void .\\) > y->_data, \\(void .\\) y->_vptr->_def_init, \\(unsigned long\\) > y->_vptr->_size\\);" 1 "original" } } That doesn't match. (void) __builtin_memcpy ((void *) y->_data, (void *) y->_vptr->_def_init, (character(kind=4)) y->_vptr->_size); Appears to be a 32/64 bit issue. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: *PING* / Re: [Patch, Fortran] Finalize nonallocatables with INTENT(out)
Dear Tobias, The test gfortran.dg/finalize_10.f90 fails in 32 bit mode (see http://gcc.gnu.org/ml/gcc-testresults/2013-06/msg00842.html FAIL: gfortran.dg/finalize_10.f90 -O scan-tree-dump-times original "__builtin_memcpy ((void .) y->_data, (void .) y->_vptr->_def_init, (unsigned long) y->_vptr->_size);" 1) because "unsigned long" is replaced with "unsigned int". The following patch fixes it --- ../_clean/gcc/testsuite/gfortran.dg/finalize_10.f90 2013-06-08 21:50:32.0 +0200 +++ gcc/testsuite/gfortran.dg/finalize_10.f90 2013-06-09 11:33:12.0 +0200 @@ -26,7 +26,8 @@ end subroutine foo ! Finalize CLASS + set default init ! { dg-final { scan-tree-dump-times "y->_vptr->_final \\(&desc.\[0-9\]+, y->_vptr->_size, 0\\);" 1 "original" } } -! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(\\(void .\\) y->_data, \\(void .\\) y->_vptr->_def_init, \\(unsigned long\\) y->_vptr->_size\\);" 1 "original" } } +! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(\\(void .\\) y->_data, \\(void .\\) y->_vptr->_def_init, \\(unsigned long\\) y->_vptr->_size\\);" 1 "original" { target lp64 } } } +! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(\\(void .\\) y->_data, \\(void .\\) y->_vptr->_def_init, \\(unsigned int\\) y->_vptr->_size\\);" 1 "original" { target ilp32 } } } ! { dg-final { scan-tree-dump-times "x->_vptr->_final \\(&x->_data, x->_vptr->_size, 0\\);" 1 "original" } } ! { dg-final { scan-tree-dump-times "x->_vptr->_copy \\(x->_vptr->_def_init, &x->_data\\);" 1 "original" } } I have tried to weaken the test by not using any target and using a regexp of the kind "(int|long)", but I did not succeeded. CAVEAT: I don't know if the targets work for x32. TIA Dominique
Re: *PING* / Re: [Patch, Fortran] Finalize nonallocatables with INTENT(out)
Hello Mikael, thanks for your patch reviews! Regarding your question: Mikael Morin worte: Le 06/06/2013 10:35, Tobias Burnus a écrit : On May 31, 2013 18:39, Tobias Burnus wrote: This patch adds finalization support for INTENT(out) for nonallocatable dummy arguments. Additionally, it addresses a missed optimization: The previous code tried to deallocate allocatable components even if the dummy argument was already an allocatable. That's a missed optimization as gfortran deallocates allocatables in the caller. Is there any reason to handle them in the caller? I don't think that there is real reason - and I don't know why Erik Edelmann and Paul have chosen to do so for GCC 4.2. In principle, either location is fine. I think I had placed it into the callee, but now we cannot change it anymore without breaking the ABI. For TS29113 (i.e. for bind(C)), the Fortran procedure has to handle the deallocate for allocatable dummys with intent(out). Thus, in that case, one needs to have the deallocation code both in the caller and in the callee. (TS29113 only permits interoperable types with ALLOCATABLE or INTENT(OUT) - noninteroperable vars (i.e. extensible types, allocatable components, finalizers etc.) can be used in BIND(C) procedures - but only with the dummy argument TYPE(*) - and hence without ALLOCATABLE and INTENT(OUT)). Tobias PS: Pending patches: * 4.8/4.9 regression: http://gcc.gnu.org/ml/fortran/2013-06/msg00047.html * CLASS as result var: http://gcc.gnu.org/ml/fortran/2013-06/msg00053.html
Re: *PING* / Re: [Patch, Fortran] Finalize nonallocatables with INTENT(out)
Hello, Le 06/06/2013 10:35, Tobias Burnus a écrit : > * PING * > > Attached is a rediff - including the later posted additional test case > (http://gcc.gnu.org/ml/fortran/2013-05/msg00141.html) > > > On May 31, 2013 18:39, Tobias Burnus wrote: >> This patch adds finalization support for INTENT(out) for >> nonallocatable dummy arguments. >> >> Additionally, it addresses a missed optimization: The previous code >> tried to deallocate allocatable components even if the dummy argument >> was already an allocatable. That's a missed optimization as gfortran >> deallocates allocatables in the caller. >> Is there any reason to handle them in the caller? The patch is OK. Mikael