]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: restore return-in-loop loopvar optimization
authorDavid Chase <drchase@google.com>
Tue, 28 Feb 2023 22:36:38 +0000 (17:36 -0500)
committerDavid Chase <drchase@google.com>
Thu, 16 Mar 2023 18:46:51 +0000 (18:46 +0000)
commit23e8f43cb1e865edeab2bad08dc01cceac3ba0b0
tree4ac602a18f5c588016f39206aedb58a27bd9d136
parentab28b834c4a38bd2295ee43eca4f9e38c28d54a2
cmd/compile: restore return-in-loop loopvar optimization

but this time, correctly.
children of Returns can have For/Range loops in them,
and those must be visited.

Includes test to verify that the optimization occurs,
and also that the problematic case that broke the original
optimization is now correctly handled.

Change-Id: If5a94fd51c862d4bfb318fec78456b7b202f3fcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/472355
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/loopvar/loopvar.go
src/cmd/compile/internal/loopvar/loopvar_test.go
src/cmd/compile/internal/loopvar/testdata/opt.go [new file with mode: 0644]