aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2023-06-23 01:04:29 +0700
committerGopher Robot <gobot@golang.org>2023-06-23 14:29:16 +0000
commit6dce882b3aad86b8c3e2928d3be6a87e425c1754 (patch)
tree90648195dcbc1b69fc9eea301ac8dc7ba0bf523e /src/cmd/compile/internal/noder
parent164aceea08a4c56b9bf451e315c5dbe3f4727971 (diff)
downloadgo-6dce882b3aad86b8c3e2928d3be6a87e425c1754.tar.xz
cmd/compile: scanning closures body when visiting wrapper function
CL 410344 fixed missing method value wrapper, by visiting body of wrapper function after applying inlining pass. CL 492017 allow more inlining of functions that construct closures, which ends up making the wrapper function now inlineable, but can contain closure nodes that couldn't be inlined. These closures body may contain OMETHVALUE nodes that we never seen, thus we need to scan closures body for finding them. Fixes #60945 Change-Id: Ia1e31420bb172ff87d7321d2da2989ef23e6ebb6 Reviewed-on: https://go-review.googlesource.com/c/go/+/505255 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/noder')
-rw-r--r--src/cmd/compile/internal/noder/reader.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go
index 70f51e2253..610d02c07c 100644
--- a/src/cmd/compile/internal/noder/reader.go
+++ b/src/cmd/compile/internal/noder/reader.go
@@ -3919,7 +3919,11 @@ func finishWrapperFunc(fn *ir.Func, target *ir.Package) {
// The body of wrapper function after inlining may reveal new ir.OMETHVALUE node,
// we don't know whether wrapper function has been generated for it or not, so
// generate one immediately here.
- ir.VisitList(fn.Body, func(n ir.Node) {
+ //
+ // Further, after CL 492017, function that construct closures is allowed to be inlined,
+ // even though the closure itself can't be inline. So we also need to visit body of any
+ // closure that we see when visiting body of the wrapper function.
+ ir.VisitFuncAndClosures(fn, func(n ir.Node) {
if n, ok := n.(*ir.SelectorExpr); ok && n.Op() == ir.OMETHVALUE {
wrapMethodValue(n.X.Type(), n.Selection, target, true)
}