This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran] PR fortran/44709: Clean up local variables with try-finally


Hi Mikael,

Mikael Morin wrote:
Le 15.07.2010 11:07, Daniel Kraft a écrit :
Hi all,

the attached patch does what I wrote about in
http://gcc.gnu.org/ml/fortran/2010-07/msg00058.html. Briefly, I modified
gfc_trans_deferred_vars and its callees such that init and cleanup code
(like memory allocation / deallocation) is collected seperately rather
than wrapped around the function body directly; this is then used to do
the clean-up with a try-finally middle-end expression, so that all exits
safely do the cleanup automagically. Which fixes the wrong-code /
memory-leak part of PR 44709.

Currently, multiple returns from procedures are handled via a jump to a
label at the end of the function, from which on the cleanup was done
before (in order to work around the problem in the PR for BLOCKs). I
think that this may no longer be needed in fact now (am I right? Or is
there another reason why we want only a single exit point from all
procedures?).
The testsuite will tell ;-)

yes, I'll just try to do that.


No regressions on GNU/Linux-x86-32, and additionally valgrind shows no
longer any memory leaks for code like that in the PR (and the tree-dump
also looks fine). This was with SVN trunk some days ago, though, so I'm
at the moment building and testing with a fresh update.

Ok for trunk if no failures with that, either?
I guess there is no way to test this in the testsuite.

FINAL would be one, but unfortunately not yet... ;)


OK then.

Committed as rev. 162219.


Thanks for the fast review!

Daniel

--
http://www.pro-vegan.info/
--
Done:  Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]