]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix defer/deferreturn
authorKeith Randall <khr@golang.org>
Thu, 10 Mar 2016 03:27:57 +0000 (19:27 -0800)
committerKeith Randall <khr@golang.org>
Thu, 10 Mar 2016 22:33:49 +0000 (22:33 +0000)
commitddc6b64444c3914621b3b1ff019e02b5aabdc20c
treedd192ae64f4abcb0bcc694702f7f5e680578c67e
parent9c8f549abbc339fce83f96d80500ab9160a4c84d
cmd/compile: fix defer/deferreturn

Make sure we do any just-before-return cleanup on all paths out of a
function, including when recovering.  Each exit path should include
deferreturn (if there are any defers) and then the exit
code (e.g. copying heap-escaping return values back to the stack).

Introduce a Defer SSA block type which has two outgoing edges - one the
fallthrough edge (the defer was queued successfully) and one which
immediately returns (the defer had a successful recover() call and
normal execution should resume at the return point).

Fixes #14725

Change-Id: Iad035c9fd25ef8b7a74dafbd7461cf04833d981f
Reviewed-on: https://go-review.googlesource.com/20486
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/check.go
src/cmd/compile/internal/ssa/flagalloc.go
src/cmd/compile/internal/ssa/gen/genericOps.go
src/cmd/compile/internal/ssa/likelyadjust.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/phiopt.go
src/cmd/compile/internal/ssa/regalloc.go
test/fixedbugs/issue14725.go [new file with mode: 0644]