]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.20] cmd/compile: fix wrong escape analysis for go/defer generic...
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 7 Feb 2023 12:28:15 +0000 (19:28 +0700)
committerMichael Pratt <mpratt@google.com>
Wed, 15 Feb 2023 21:46:55 +0000 (21:46 +0000)
commit2d01f3695becd725959a723b512cf46e88ae60fe
treed2eb2b799a3ca7b7a40c9d633b76624d54e48f02
parent965e9ba0fb6ed8b511860beaefa7a3ac97a81c36
[release-branch.go1.20] cmd/compile: fix wrong escape analysis for go/defer generic calls

For go/defer calls like "defer f(x, y)", the compiler rewrites it to:

x1, y1 := x, y
defer func() { f(x1, y1) }()

However, if "f" needs runtime type information, the "RType" field will
refer to the outer ".dict" param, causing wrong liveness analysis.

To fix this, if "f" refers to outer ".dict", the dict param will be
copied to an autotmp, and "f" will refer to this autotmp instead.

Fixes #58467

Change-Id: I238b6e75441442b5540d39bc818205398e80c94d
Reviewed-on: https://go-review.googlesource.com/c/go/+/466035
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/467935
Reviewed-by: Michael Pratt <mpratt@google.com>
src/cmd/compile/internal/escape/call.go
test/fixedbugs/issue58341.go [new file with mode: 0644]