mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
9c8f549abb
commit
ddc6b64444
9 changed files with 124 additions and 58 deletions
|
|
@ -401,6 +401,7 @@ var genericBlocks = []blockData{
|
|||
{name: "Plain"}, // a single successor
|
||||
{name: "If"}, // 2 successors, if control goto Succs[0] else goto Succs[1]
|
||||
{name: "Call"}, // 1 successor, control is call op (of memory type)
|
||||
{name: "Defer"}, // 2 successors, Succs[0]=defer queued, Succs[1]=defer recovered. control is call op (of memory type)
|
||||
{name: "Check"}, // 1 successor, control is nilcheck op (of void type)
|
||||
{name: "Ret"}, // no successors, control value is memory result
|
||||
{name: "RetJmp"}, // no successors, jumps to b.Aux.(*gc.Sym)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue