diff options
author | David Chase <drchase@google.com> | 2021-03-10 20:54:11 -0500 |
---|---|---|
committer | David Chase <drchase@google.com> | 2021-03-15 20:48:37 +0000 |
commit | 8ed438c077d82c4b4662c327dbbdb3c64e7547ca (patch) | |
tree | 7557794f1e7d4c78ed445d398f9c5d4401313e57 /test/abi | |
parent | 96aecdcb36ad5240a9858f7f7d77ace30f2deaaa (diff) | |
download | go-8ed438c077d82c4b4662c327dbbdb3c64e7547ca.tar.gz go-8ed438c077d82c4b4662c327dbbdb3c64e7547ca.zip |
cmd/compile: spill output parameters passed in registers as autos
ALSO:
found evidence that stack maps for bodyless methods are wrong.
gofmt in test/abi
removed never-executed code in types/size.go
Updates #44816.
Change-Id: I658c33f049337fb6f1e625f0c55430d25bfa877e
Reviewed-on: https://go-review.googlesource.com/c/go/+/300749
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'test/abi')
-rw-r--r-- | test/abi/fibish2.go | 4 | ||||
-rw-r--r-- | test/abi/leaf.go | 36 | ||||
-rw-r--r-- | test/abi/leaf2.go | 43 | ||||
-rw-r--r-- | test/abi/methods.go | 11 | ||||
-rw-r--r-- | test/abi/spills3.go | 48 | ||||
-rw-r--r-- | test/abi/spills4.go | 44 |
6 files changed, 179 insertions, 7 deletions
diff --git a/test/abi/fibish2.go b/test/abi/fibish2.go index 14f3f9ada7..388aabc8b0 100644 --- a/test/abi/fibish2.go +++ b/test/abi/fibish2.go @@ -13,12 +13,12 @@ import "fmt" // Test that register results are correctly returned (and passed) -type MagicLastTypeNameForTestingRegisterABI func(int,MagicLastTypeNameForTestingRegisterABI) int +type MagicLastTypeNameForTestingRegisterABI func(int, MagicLastTypeNameForTestingRegisterABI) int //go:registerparams //go:noinline func minus(decrement int) MagicLastTypeNameForTestingRegisterABI { - return MagicLastTypeNameForTestingRegisterABI( func(x int, _ MagicLastTypeNameForTestingRegisterABI) int { return x-decrement} ) + return MagicLastTypeNameForTestingRegisterABI(func(x int, _ MagicLastTypeNameForTestingRegisterABI) int { return x - decrement }) } //go:noinline diff --git a/test/abi/leaf.go b/test/abi/leaf.go new file mode 100644 index 0000000000..f893f5dddb --- /dev/null +++ b/test/abi/leaf.go @@ -0,0 +1,36 @@ +// run + +//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. + +// wasm is excluded because the compiler chatter about register abi pragma ends up +// on stdout, and causes the expected output to not match. + +package main + +import "fmt" + +type i5f5 struct { + a, b int16 + c, d, e int32 + r, s, t, u, v float32 +} + +//go:registerparams +//go:noinline +func F(x i5f5) i5f5 { + return x +} + +func main() { + x := i5f5{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + y := x + z := F(x) + if y != z { + fmt.Printf("y=%v, z=%v\n", y, z) + } +} diff --git a/test/abi/leaf2.go b/test/abi/leaf2.go new file mode 100644 index 0000000000..d2018d5313 --- /dev/null +++ b/test/abi/leaf2.go @@ -0,0 +1,43 @@ +// run + +//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. + +// wasm is excluded because the compiler chatter about register abi pragma ends up +// on stdout, and causes the expected output to not match. + +package main + +import "fmt" + +type i4 struct { + a, b, c, d int +} + +//go:registerparams +//go:noinline +func F(x i4) i4 { + ab := x.a + x.b + bc := x.b + x.c + cd := x.c + x.d + ad := x.a + x.d + ba := x.a - x.b + cb := x.b - x.c + dc := x.c - x.d + da := x.a - x.d + + return i4{ab*bc + da, cd*ad + cb, ba*cb + ad, dc*da + bc} +} + +func main() { + x := i4{1, 2, 3, 4} + y := x + z := F(x) + if (i4{12, 34, 6, 8}) != z { + fmt.Printf("y=%v, z=%v\n", y, z) + } +} diff --git a/test/abi/methods.go b/test/abi/methods.go index 9ecae9833e..3dcd3e327a 100644 --- a/test/abi/methods.go +++ b/test/abi/methods.go @@ -14,7 +14,7 @@ import ( ) type toobig struct { - a,b,c string + a, b, c string } //go:registerparams @@ -29,8 +29,8 @@ type AnInterface interface { //go:registerparams //go:noinline -func I(a,b,c string) toobig { - return toobig{a,b,c} +func I(a, b, c string) toobig { + return toobig{a, b, c} } // AnIid prevents the compiler from figuring out what the interface really is. @@ -40,12 +40,13 @@ func AnIid(x AnInterface) AnInterface { } var tmp toobig + func main() { x := I("Ahoy", "1,", "2") y := I("3", "there,", "4") z := I("5", "6,", "Matey") - tmp = x.MagicMethodNameForTestingRegisterABI(y,z) + tmp = x.MagicMethodNameForTestingRegisterABI(y, z) fmt.Println(tmp.a, tmp.b, tmp.c) - tmp = AnIid(&x).MagicMethodNameForTestingRegisterABI(y,z) + tmp = AnIid(&x).MagicMethodNameForTestingRegisterABI(y, z) fmt.Println(tmp.a, tmp.b, tmp.c) } diff --git a/test/abi/spills3.go b/test/abi/spills3.go new file mode 100644 index 0000000000..247828437b --- /dev/null +++ b/test/abi/spills3.go @@ -0,0 +1,48 @@ +// run + +//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. + +// wasm is excluded because the compiler chatter about register abi pragma ends up +// on stdout, and causes the expected output to not match. + +package main + +import "fmt" + +type i4 struct { + a, b, c, d int +} + +//go:noinline +func spills(px *i4) { +} + +//go:registerparams +//go:noinline +func F(x i4) i4 { + ab := x.a + x.b + bc := x.b + x.c + cd := x.c + x.d + ad := x.a + x.d + ba := x.a - x.b + cb := x.b - x.c + dc := x.c - x.d + da := x.a - x.d + i := i4{ab*bc + da, cd*ad + cb, ba*cb + ad, dc*da + bc} + spills(&i) + return i +} + +func main() { + x := i4{1, 2, 3, 4} + y := x + z := F(x) + if z != (i4{12, 34, 6, 8}) { + fmt.Printf("y=%v, z=%v\n", y, z) + } +} diff --git a/test/abi/spills4.go b/test/abi/spills4.go new file mode 100644 index 0000000000..205f5a64c0 --- /dev/null +++ b/test/abi/spills4.go @@ -0,0 +1,44 @@ +// run + +//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. + +// wasm is excluded because the compiler chatter about register abi pragma ends up +// on stdout, and causes the expected output to not match. + +package main + +import "fmt" + +type i5f5 struct { + a, b int16 + c, d, e int32 + r, s, t, u, v float32 +} + +//go:noinline +func spills(_ *float32) { + +} + +//go:registerparams +//go:noinline +func F(x i5f5) i5f5 { + y := x.v + spills(&y) + x.r = y + return x +} + +func main() { + x := i5f5{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + y := x + z := F(x) + if (i5f5{1, 2, 3, 4, 5, 10, 7, 8, 9, 10}) != z { + fmt.Printf("y=%v, z=%v\n", y, z) + } +} |