• Keith Randall's avatar
    cmd/compile: fix defer/deferreturn · ddc6b644
    Keith Randall authored
    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/20486Reviewed-by: 's avatarDavid Chase <drchase@google.com>
    ddc6b644
issue14725.go 857 Bytes