diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2023-08-16 22:37:42 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-08-17 19:37:04 +0000 |
| commit | 2c51ea11b0f96ece871f84f83fb393ff80ec8f4a (patch) | |
| tree | 08a8bca8c7d6a2cfe7b12233e1552a30ab537558 /test/fixedbugs | |
| parent | 7e2e648a2d55547f0e541668b893329ec195691a (diff) | |
| download | go-2c51ea11b0f96ece871f84f83fb393ff80ec8f4a.tar.xz | |
cmd/compile/internal/typecheck: push ONEW into go/defer wrappers
Currently, we rewrite:
go f(new(T))
into:
tmp := new(T)
go func() { f(tmp) }()
However, we can both shrink the closure and improve escape analysis by
instead rewriting it into:
go func() { f(new(T)) }()
This CL does that.
Change-Id: Iae16a476368da35123052ca9ff41c49159980458
Reviewed-on: https://go-review.googlesource.com/c/go/+/520340
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'test/fixedbugs')
| -rw-r--r-- | test/fixedbugs/issue31573.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/test/fixedbugs/issue31573.go b/test/fixedbugs/issue31573.go index a0cff3099a..5197163f04 100644 --- a/test/fixedbugs/issue31573.go +++ b/test/fixedbugs/issue31573.go @@ -19,31 +19,31 @@ func g() { defer f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" go f() - go f(new(int)) // ERROR "... argument does not escape$" "new\(int\) escapes to heap$" - go f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) escapes to heap$" + go f(new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" + go f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" go f(nil...) go f([]*int{}...) // ERROR "\[\]\*int{} does not escape$" - go f([]*int{new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) escapes to heap$" - go f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) escapes to heap$" + go f([]*int{new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" + go f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" for { defer f() - defer f(new(int)) // ERROR "... argument does not escape$" "new\(int\) escapes to heap$" - defer f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) escapes to heap$" + defer f(new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" + defer f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" defer f(nil...) defer f([]*int{}...) // ERROR "\[\]\*int{} does not escape$" - defer f([]*int{new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) escapes to heap$" - defer f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) escapes to heap$" + defer f([]*int{new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" + defer f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" go f() - go f(new(int)) // ERROR "... argument does not escape$" "new\(int\) escapes to heap$" - go f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) escapes to heap$" + go f(new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" + go f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" go f(nil...) go f([]*int{}...) // ERROR "\[\]\*int{} does not escape$" - go f([]*int{new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) escapes to heap$" - go f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) escapes to heap$" + go f([]*int{new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" + go f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" } } |
