[dev.unified] cmd/compile: special case f(g()) calls in Unified IR

For f(g()) calls where g() is multi-valued, we may need to insert
implicit conversions to convert g()'s result values to f()'s parameter
types. This CL refactors code slightly so this will be easier to
handle.

Change-Id: I3a432220dcb62daecf9a66030e8fa1f097e95f95
Reviewed-on: https://go-review.googlesource.com/c/go/+/413362
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Matthew Dempsky 2022-06-21 04:41:38 -07:00
parent 61ae2b734c
commit 20e1d5ac8c
2 changed files with 30 additions and 4 deletions

View file

@ -1735,8 +1735,15 @@ func (r *reader) expr() (res ir.Node) {
fun = typecheck.Callee(ir.NewSelectorExpr(pos, ir.OXDOT, fun, sym))
}
pos := r.pos()
args := r.exprs()
dots := r.Bool()
var args ir.Nodes
var dots bool
if r.Bool() { // f(g())
call := r.expr()
args = []ir.Node{call}
} else {
args = r.exprs()
dots = r.Bool()
}
n := typecheck.Call(pos, fun, args, dots)
switch n.Op() {
case ir.OAPPEND: