]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: load results into registers on open defer return path
authorCherry Zhang <cherryyz@google.com>
Sun, 4 Apr 2021 00:09:15 +0000 (20:09 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 6 Apr 2021 20:22:15 +0000 (20:22 +0000)
commitf5efa5a313cbfdbd86aa342f8bc2a4cc66f51a6e
treecdbe97e33471553618e9ef442bbdd134827b8945
parentbcc4422ee1bdb8051a6c870cf00e837814614a0f
cmd/compile: load results into registers on open defer return path

When a function panics then recovers, it needs to return to the
caller with named results having the correct values. For
in-register results, we need to load them into registers at the
defer return path.

For non-open-coded defers, we already generate correct code, as
the defer return path is part of the SSA CFG and contains the
instructions that are the same as an ordinary return statement,
including putting the results to the right places.

For open-coded defers, we have a special code generation that
emits a disconnected block that currently contains only the
deferreturn call and a RET instruction. It leaves the result
registers unset. This CL adds instructions that load the result
registers on that path.

Updates #40724.

Change-Id: I1f60514da644fd5fb4b4871a1153c62f42927282
Reviewed-on: https://go-review.googlesource.com/c/go/+/307231
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/compile/internal/amd64/galign.go
src/cmd/compile/internal/amd64/ssa.go
src/cmd/compile/internal/ssa/op.go
src/cmd/compile/internal/ssagen/arch.go
src/cmd/compile/internal/ssagen/ssa.go
test/abi/defer_recover_results.go [new file with mode: 0644]