aboutsummaryrefslogtreecommitdiff
path: root/test/reorder.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-01-16 03:27:17 -0800
committerMatthew Dempsky <mdempsky@google.com>2021-01-16 23:19:26 +0000
commit6de9423445840351a4cc7b17d732f0b5e922ef1a (patch)
treec87fd42a62d5fbe58495ddbd5abd4fd77c352888 /test/reorder.go
parenta956a0e909e1d60c8d55339e5e591a9d1db885c4 (diff)
downloadgo-6de9423445840351a4cc7b17d732f0b5e922ef1a.tar.gz
go-6de9423445840351a4cc7b17d732f0b5e922ef1a.zip
[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>
Diffstat (limited to 'test/reorder.go')
-rw-r--r--test/reorder.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/reorder.go b/test/reorder.go
index 3a87d025c2..57892f882f 100644
--- a/test/reorder.go
+++ b/test/reorder.go
@@ -20,6 +20,8 @@ func main() {
p7()
p8()
p9()
+ p10()
+ p11()
}
var gx []int
@@ -149,3 +151,17 @@ func checkOAS2XXX(x bool, s string) {
panic("failed")
}
}
+
+//go:noinline
+func fp() (*int, int) { return nil, 42 }
+
+func p10() {
+ p := new(int)
+ p, *p = fp()
+}
+
+func p11() {
+ var i interface{}
+ p := new(bool)
+ p, *p = i.(*bool)
+}