aboutsummaryrefslogtreecommitdiff
path: root/test/abi
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2021-03-05 21:09:40 -0500
committerDavid Chase <drchase@google.com>2021-03-09 18:44:23 +0000
commit98dfdc82c85c238a5ab6131d6f1e86e0da259851 (patch)
tree0482d2950cabcef94b5e99500b1a87b12f4ae992 /test/abi
parent5eb99120844c0494d655678262e1fb41949a2b99 (diff)
downloadgo-98dfdc82c85c238a5ab6131d6f1e86e0da259851.tar.gz
go-98dfdc82c85c238a5ab6131d6f1e86e0da259851.zip
cmd/compile: fix broken type+offset calc for register args
Includes more enhancements to debugging output. Updates #44816. Change-Id: I5b21815cf37ed21e7dec6c06f538090f32260203 Reviewed-on: https://go-review.googlesource.com/c/go/+/299409 Trust: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'test/abi')
-rw-r--r--test/abi/bad_internal_offsets.go74
1 files changed, 74 insertions, 0 deletions
diff --git a/test/abi/bad_internal_offsets.go b/test/abi/bad_internal_offsets.go
new file mode 100644
index 0000000000..d396c1a60f
--- /dev/null
+++ b/test/abi/bad_internal_offsets.go
@@ -0,0 +1,74 @@
+// compile
+
+//go:build !wasm
+// +build !wasm
+
+// 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 genChecker0
+
+var FailCount int
+
+//go:noinline
+func NoteFailure(fidx int, pkg string, pref string, parmNo int, _ uint64) {
+ FailCount += 1
+ if FailCount > 10 {
+ panic("bad")
+ }
+}
+
+//go:noinline
+func NoteFailureElem(fidx int, pkg string, pref string, parmNo int, elem int, _ uint64) {
+ FailCount += 1
+ if FailCount > 10 {
+ panic("bad")
+ }
+}
+
+type StructF0S0 struct {
+ F0 int16
+ F1 string
+ F2 StructF0S1
+}
+
+type StructF0S1 struct {
+ _ uint16
+}
+
+// 0 returns 3 params
+//go:registerparams
+//go:noinline
+func Test0(p0 uint32, p1 StructF0S0, p2 int32) {
+ // consume some stack space, so as to trigger morestack
+ var pad [256]uint64
+ pad[FailCount]++
+ if p0 == 0 {
+ return
+ }
+ p1f0c := int16(-3096)
+ if p1.F0 != p1f0c {
+ NoteFailureElem(0, "genChecker0", "parm", 1, 0, pad[0])
+ return
+ }
+ p1f1c := "f6ꂅ8ˋ<"
+ if p1.F1 != p1f1c {
+ NoteFailureElem(0, "genChecker0", "parm", 1, 1, pad[0])
+ return
+ }
+ p1f2c := StructF0S1{}
+ if p1.F2 != p1f2c {
+ NoteFailureElem(0, "genChecker0", "parm", 1, 2, pad[0])
+ return
+ }
+ p2f0c := int32(496713155)
+ if p2 != p2f0c {
+ NoteFailureElem(0, "genChecker0", "parm", 2, 0, pad[0])
+ return
+ }
+ // recursive call
+ Test0(p0-1, p1, p2)
+ return
+ // 0 addr-taken params, 0 addr-taken returns
+}