go/src/cmd/compile/internal/loopvar
David Chase 23e8f43cb1 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>
2023-03-16 18:46:51 +00:00
..
testdata cmd/compile: restore return-in-loop loopvar optimization 2023-03-16 18:46:51 +00:00
loopvar.go cmd/compile: restore return-in-loop loopvar optimization 2023-03-16 18:46:51 +00:00
loopvar_test.go cmd/compile: restore return-in-loop loopvar optimization 2023-03-16 18:46:51 +00:00