aboutsummaryrefslogtreecommitdiff
path: root/test/closure3.dir
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2020-09-21 20:20:00 -0700
committerMatthew Dempsky <mdempsky@google.com>2020-10-15 18:26:33 +0000
commit497ea0610ea3757c6171cae3a85627459b572e5d (patch)
tree78b616d2c3364893290d845523d640c59cda9b23 /test/closure3.dir
parentc0417df15664a84c3cc6de8292f78debce111def (diff)
downloadgo-497ea0610ea3757c6171cae3a85627459b572e5d.tar.gz
go-497ea0610ea3757c6171cae3a85627459b572e5d.zip
cmd/compile: allow inlining of "for" loops
We already allow inlining "if" and "goto" statements, so we might as well allow "for" loops too. The majority of frontend support is already there too. The critical missing feature at the moment is that inlining doesn't properly reassociate OLABEL nodes with their control statement (e.g., OFOR) after inlining. This eventually causes SSA construction to fail. As a workaround, this CL only enables inlining for unlabeled "for" loops. It's left to a (yet unplanned) future CL to add support for labeled "for" loops. The increased opportunity for inlining leads to a small growth in binary size. For example: $ size go.old go.new text data bss dec hex filename 9740163 320064 230656 10290883 9d06c3 go.old 9793399 320064 230656 10344119 9dd6b7 go.new Updates #14768. Fixes #41474. Change-Id: I827db0b2b9d9fa2934db05caf6baa463f0cd032a Reviewed-on: https://go-review.googlesource.com/c/go/+/256459 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'test/closure3.dir')
-rw-r--r--test/closure3.dir/main.go3
1 files changed, 1 insertions, 2 deletions
diff --git a/test/closure3.dir/main.go b/test/closure3.dir/main.go
index 3ec90139a3..5694673f1e 100644
--- a/test/closure3.dir/main.go
+++ b/test/closure3.dir/main.go
@@ -238,8 +238,7 @@ func main() {
if c != 4 {
ppanic("c != 4")
}
- for i := 0; i < 10; i++ { // prevent inlining
- }
+ recover() // prevent inlining
}()
}()
if c != 4 {