aboutsummaryrefslogtreecommitdiff
path: root/test/abi
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2021-03-31 12:41:20 -0400
committerCherry Zhang <cherryyz@google.com>2021-03-31 20:21:57 +0000
commit5d6581d74796ac748441c94e84eefdaf338d266c (patch)
tree3dd34175d091279046ec7a7ad175cc109fcf0266 /test/abi
parent4acefa07b1499b063e1ff63c9d4cab7b7f8d49a2 (diff)
downloadgo-5d6581d74796ac748441c94e84eefdaf338d266c.tar.gz
go-5d6581d74796ac748441c94e84eefdaf338d266c.zip
cmd/compile: deduplicate OpArg's across types
For in-register arguments, it must have only a single copy of it present in the function. If there are multiple copies, it confuses the register allocator, as they are in the same register. Change-Id: I55cb06746f08aa7c9168026d0f411bce0a9f93f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/306330 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'test/abi')
-rw-r--r--test/abi/defer_aggregate.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/abi/defer_aggregate.go b/test/abi/defer_aggregate.go
new file mode 100644
index 0000000000..6dd82828c1
--- /dev/null
+++ b/test/abi/defer_aggregate.go
@@ -0,0 +1,48 @@
+// run
+
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+const p0exp = "foo"
+const p1exp = 10101
+const p2exp = 3030303
+const p3exp = 505050505
+const p4exp = 70707070707
+
+//go:noinline
+//go:registerparams
+func callee(p0 string, p1 uint64, p2 uint64, p3 uint64, p4 uint64) {
+ if p0 != p0exp {
+ panic("bad p0")
+ }
+ if p1 != p1exp {
+ panic("bad p1")
+ }
+ if p2 != p2exp {
+ panic("bad p2")
+ }
+ if p3 != p3exp {
+ panic("bad p3")
+ }
+ if p4 != p4exp {
+ panic("bad p4")
+ }
+ defer func(p0 string, p2 uint64) {
+ if p0 != p0exp {
+ panic("defer bad p0")
+ }
+ if p1 != p1exp {
+ panic("defer bad p1")
+ }
+ if p2 != p2exp {
+ panic("defer bad p2")
+ }
+ }(p0, p2)
+}
+
+func main() {
+ callee(p0exp, p1exp, p2exp, p3exp, p4exp)
+}