]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: deadcode unreferenced hidden closures during inlining
authorThan McIntosh <thanm@google.com>
Tue, 4 Apr 2023 22:56:21 +0000 (18:56 -0400)
committerThan McIntosh <thanm@google.com>
Fri, 7 Apr 2023 15:07:18 +0000 (15:07 +0000)
commitf1caf1aa1c45e014e35316da8e0d2edf48795bf6
tree98759ea67fc3dab2f2337846c120dfc92ff759bc
parentd7d235c92f1329359194a8c042b2099ef60ec17c
cmd/compile: deadcode unreferenced hidden closures during inlining

When a closure is inlined, it may contain other hidden closures, which
the inliner will duplicate, rendering the original nested closures as
unreachable. Because they are unreachable, they don't get processed in
escape analysis, meaning that go/defer statements don't get rewritten,
which can then in turn trigger errors in walk. This patch looks for
nested hidden closures and marks them as dead, so that they can be
skipped later on in the compilation flow.  NB: if during escape
analysis we rediscover a hidden closure (due to an explicit reference)
that was previously marked dead, revive it at that point.

Fixes #59404.

Change-Id: I76db1e9cf1ee38bd1147aeae823f916dbbbf081b
Reviewed-on: https://go-review.googlesource.com/c/go/+/482355
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/inline/inl.go
test/fixedbugs/issue59404.go [new file with mode: 0644]
test/fixedbugs/issue59404part2.go [new file with mode: 0644]