diff options
author | Matthew Dempsky <mdempsky@google.com> | 2022-06-28 16:31:29 -0700 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2022-06-30 18:42:24 +0000 |
commit | 3635b07d16c9fe3f344b3271fb3bf7029d8b4001 (patch) | |
tree | a3aa4eb2bc357656521d274417946ca2b7d9944e /test/escape_iface_unified.go | |
parent | e7219cc093aca07bdb7179fa1a42d44e56eaf9d4 (diff) | |
download | go-git-3635b07d16c9fe3f344b3271fb3bf7029d8b4001.tar.gz |
[dev.unified] cmd/compile/internal/noder: implicit conversions for multi-valued expressions
This CL changes GOEXPERIMENT=unified to insert implicit conversions
for multi-valued expressions.
Unfortunately, IR doesn't have strong, first-class support for
multi-valued expressions, so this CL takes the approach of spilling
them to temporary variables, which can then be implicitly converted.
This is the same approach taken by walk, but doing it this early does
introduce some minor complications:
1. For select case clauses with comma-ok assignments (e.g., `case x,
ok := <-ch:`), the compiler middle end wants to see the OAS2RECV
assignment is the CommClause.Comm statement. So when constructing
select statements, we need to massage this around a little.
2. The extra temporary variables and assignments skew the existing
inlining heuristics. As mentioned, the temporaries/assignments will
eventually be added (and often optimized away again) anyway, but now
they're visible to the inliner. So this CL also kludges the inlining
heuristics in this case to keep things comparable.
Change-Id: I3e3ea756ad92472ebe28bae3963be61ed7684a75
Reviewed-on: https://go-review.googlesource.com/c/go/+/415244
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'test/escape_iface_unified.go')
-rw-r--r-- | test/escape_iface_unified.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/test/escape_iface_unified.go b/test/escape_iface_unified.go index 7ac8e00151..80222dae5f 100644 --- a/test/escape_iface_unified.go +++ b/test/escape_iface_unified.go @@ -18,8 +18,7 @@ func dotTypeEscape2() { // #13805, #15796 var x interface{} = i // ERROR "i does not escape" var y interface{} = j // ERROR "j does not escape" - sink = x.(int) // ERROR "x.\(int\) escapes to heap" - // BAD: should be "y.\(int\) escapes to heap" too - sink, *(&ok) = y.(int) + sink = x.(int) // ERROR "x.\(int\) escapes to heap" + sink, *(&ok) = y.(int) // ERROR "autotmp_.* escapes to heap" } } |