aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-expand.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2018-01-15 19:13:47 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-01-15 19:13:47 +0000
commit7c3bc15e4a2aba3eb43d59624d646bbdbff60a83 (patch)
treecc0acfcf32f205c7abfac4cada88e3136e992ca0 /gcc/omp-expand.c
parent64b1806b2d94fd325759761b64fb7507ca83d5d2 (diff)
downloadgcc-7c3bc15e4a2aba3eb43d59624d646bbdbff60a83.zip
gcc-7c3bc15e4a2aba3eb43d59624d646bbdbff60a83.tar.gz
gcc-7c3bc15e4a2aba3eb43d59624d646bbdbff60a83.tar.bz2
compiler: make sure variables captured by defer closure live
Local variables captured by the deferred closure need to be live until the function finishes, especially when the deferred function runs. In Function::build, for function that has a defer, we wrap 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. Fix this by creating top-level declarations for non-escaping address-taken locals when there is a defer. An example of miscompilation without this CL: func F(fn func()) { didPanic := true defer func() { println(didPanic) }() fn() didPanic = false } With escape analysis turned on, at optimization level -O1 or -O2, the store "didPanic = false" is elided by the backend's optimizer, presumably because it thinks "didPanic" is not live after the store, so the store is useless. Reviewed-on: https://go-review.googlesource.com/86241 From-SVN: r256706
Diffstat (limited to 'gcc/omp-expand.c')
0 files changed, 0 insertions, 0 deletions