aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2023-08-16 22:37:42 -0700
committerGopher Robot <gobot@golang.org>2023-08-17 19:37:04 +0000
commit2c51ea11b0f96ece871f84f83fb393ff80ec8f4a (patch)
tree08a8bca8c7d6a2cfe7b12233e1552a30ab537558 /src/cmd/compile
parent7e2e648a2d55547f0e541668b893329ec195691a (diff)
downloadgo-2c51ea11b0f96ece871f84f83fb393ff80ec8f4a.tar.gz
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 'src/cmd/compile')
-rw-r--r--src/cmd/compile/internal/typecheck/stmt.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/typecheck/stmt.go b/src/cmd/compile/internal/typecheck/stmt.go
index 4c21f045af..93a147c335 100644
--- a/src/cmd/compile/internal/typecheck/stmt.go
+++ b/src/cmd/compile/internal/typecheck/stmt.go
@@ -241,7 +241,7 @@ func tcGoDefer(n *ir.GoDeferStmt) {
// the wrapper, so we don't need to allocate space for them within
// the closure.
switch arg.Op() {
- case ir.OLITERAL, ir.ONIL, ir.OMETHEXPR:
+ case ir.OLITERAL, ir.ONIL, ir.OMETHEXPR, ir.ONEW:
return
case ir.ONAME:
arg := arg.(*ir.Name)