New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: rewrite f(g()) to use OAS2FUNC earlier #29197
Comments
Change https://golang.org/cl/153841 mentions this issue: |
I uploaded CL 153841 as a proof-of-concept of the idea. It mostly works with two notable caveats:
|
CL 153841 addresses these concerns now:
Inlining sees the post-rewrite form, which means I'll send the CL out for review once the next dev cycle opens. |
And for the record, here's a memory corruption bug due to escape analysis mishandling implicit conversions in f(g()) calls:
(Note that this is distinct from the test case in #29353.) |
Change https://golang.org/cl/166983 mentions this issue: |
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
ordelete
. Until 1602e49 it didn't work withcomplex
either.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]int
boxes forf(g())
, but theOCONVIFACE
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())
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.
The text was updated successfully, but these errors were encountered: