diff options
author | Matthew Dempsky <mdempsky@google.com> | 2023-08-17 14:15:04 -0700 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-08-18 11:58:37 +0000 |
commit | 925d2fb36c8e4c9c0e6e240a1621db36c34e5d31 (patch) | |
tree | 2394fb00600d937042524a80e59da78d540e8ffe /test/inline_big.go | |
parent | 243c8c0eec20d981d8e76a3aac82f97cca991571 (diff) | |
download | go-925d2fb36c8e4c9c0e6e240a1621db36c34e5d31.tar.gz go-925d2fb36c8e4c9c0e6e240a1621db36c34e5d31.zip |
cmd/compile: restore zero-copy string->[]byte optimization
This CL implements the remainder of the zero-copy string->[]byte
conversion optimization initially attempted in go.dev/cl/520395, but
fixes the tracking of mutations due to ODEREF/ODOTPTR assignments, and
adds more comprehensive tests that I should have included originally.
However, this CL also keeps it behind the -d=zerocopy flag. The next
CL will enable it by default (for easier rollback).
Updates #2205.
Change-Id: Ic330260099ead27fc00e2680a59c6ff23cb63c2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/520599
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'test/inline_big.go')
-rw-r--r-- | test/inline_big.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/inline_big.go b/test/inline_big.go index f579fc0910..7dd1abdb6a 100644 --- a/test/inline_big.go +++ b/test/inline_big.go @@ -9,18 +9,18 @@ package foo -func small(a []int) int { // ERROR "can inline small with cost .* as:.*" "a does not escape" "does not mutate param: a" "does not call param: a" +func small(a []int) int { // ERROR "can inline small with cost .* as:.*" "a does not escape" // Cost 16 body (need cost < 20). // See cmd/compile/internal/gc/inl.go:inlineBigFunction* return a[0] + a[1] + a[2] + a[3] } -func medium(a []int) int { // ERROR "can inline medium with cost .* as:.*" "a does not escape" "does not mutate param: a" "does not call param: a" +func medium(a []int) int { // ERROR "can inline medium with cost .* as:.*" "a does not escape" // Cost 32 body (need cost > 20 and cost < 80). // See cmd/compile/internal/gc/inl.go:inlineBigFunction* return a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] } -func f(a []int) int { // ERROR "cannot inline f:.*" "a does not escape" "function f considered 'big'" "mutates param: a derefs=0" "does not call param: a" +func f(a []int) int { // ERROR "cannot inline f:.*" "a does not escape" "function f considered 'big'" // Add lots of nodes to f's body. We need >5000. // See cmd/compile/internal/gc/inl.go:inlineBigFunction* a[0] = 0 |