Currently, there's a bunch of complexity from handling f(g()) where g is multi-valued.
For example, there's #15992, where it doesn't work when f is copy or delete. Until 1602e49 it didn't work with complex either.
It makes variadic functions and implicit conversions to interface type more complicated too. For example, given
//go:noescape
func f(a, b interface{})
func g() (a, b [4]int)
it should be possible to stack allocate the [4]int boxes for f(g()), but the OCONVIFACE nodes aren't even introduced until order.go, so esc.go has no way to mark them as non-escaping and currently they're heap allocated.
order.go (callArgs/copyRet) already rewrites f(g()) into t1, t2, .., tn := g(); f(t1, t2, ..., tn). I think we should do that during type checking instead.
A side benefit will be that we can also rewrite calls to variadic functions to always use a slice parameter (i.e., the ... call form), which should simplify various call-site logic too.
I feel like there have been other subtleties around multi-value and variadic functions, so I expect this should help improve compiler robustness.
Currently, there's a bunch of complexity from handling f(g()) where g is multi-valued.
For example, there's #15992, where it doesn't work when f is
copyordelete. Until 1602e49 it didn't work withcomplexeither.It makes variadic functions and implicit conversions to interface type more complicated too. For example, given
it should be possible to stack allocate the
[4]intboxes forf(g()), but theOCONVIFACEnodes aren't even introduced until order.go, so esc.go has no way to mark them as non-escaping and currently they're heap allocated.order.go (callArgs/copyRet) already rewrites
f(g())intot1, t2, .., tn := g(); f(t1, t2, ..., tn). I think we should do that during type checking instead.A side benefit will be that we can also rewrite calls to variadic functions to always use a slice parameter (i.e., the
...call form), which should simplify various call-site logic too.I feel like there have been other subtleties around multi-value and variadic functions, so I expect this should help improve compiler robustness.