]> Cypherpunks repositories - gostls13.git/commit
[dev.regabi] cmd/compile: cleanup OAS2FUNC ordering
authorMatthew Dempsky <mdempsky@google.com>
Sat, 16 Jan 2021 11:27:17 +0000 (03:27 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Sat, 16 Jan 2021 23:19:26 +0000 (23:19 +0000)
commit6de9423445840351a4cc7b17d732f0b5e922ef1a
treec87fd42a62d5fbe58495ddbd5abd4fd77c352888
parenta956a0e909e1d60c8d55339e5e591a9d1db885c4
[dev.regabi] cmd/compile: cleanup OAS2FUNC ordering

Currently, to ensure OAS2FUNC results are assigned in the correct
order, they're always assigned to temporary variables. However, these
temporary variables are typed based on the destination type, which may
require an interface conversion. This means walk may have to then
introduce a second set of temporaries to ensure result parameters are
all copied out of the results area, before it emits calls to runtime
conversion functions.

That's just silly. Instead, this CL changes order to allocate the
result temporaries with the same type as the function returns in the
first place, and then assign them one at a time to their destinations,
with conversions as needed.

While here, also fix an order-of-evaluation issue with has-ok
assignments that I almost added to multi-value function call
assignments, and add tests for each.

Change-Id: I9f4e962425fe3c5e3305adbbfeae2c7f253ec365
Reviewed-on: https://go-review.googlesource.com/c/go/+/284220
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/walk/assign.go
src/cmd/compile/internal/walk/order.go
test/reorder.go