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]

Go patch committed: keep variables captured by defer alive


Local variables captured by the deferred closure need to be live until
the function finishes, especially when the deferred function runs.
Function::build, for functions that have a defer, wraps the function
body in a try block.  So the backend sees the local variables only
live in the try block, without knowing that they are needed also in
the finally block where we invoke the deferred function.  This patch
to the Go frontend by Cherry Zhang fixes this by creating top-level
declarations for non-escaping address-taken locals when there is a
defer.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.

Ian

Attachment: patch.txt
Description: Text document


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