1
0
mirror of https://github.com/golang/go synced 2024-11-07 23:16:14 -07:00
go/test/abi/methods.go
David Chase e61c9ddb7f Revert "cmd/compile: spill output parameters passed in registers as autos"
This reverts commit 8ed438c077, CL 300749.

Reason for revert: Looks like it crashes on link-register architectures

Change-Id: I0c261df58900008cada3359889d2a87508158447
Reviewed-on: https://go-review.googlesource.com/c/go/+/302053
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-15 21:28:45 +00:00

52 lines
1.0 KiB
Go

// 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.
package main
import (
"fmt"
)
type toobig struct {
a,b,c string
}
//go:registerparams
//go:noinline
func (x *toobig) MagicMethodNameForTestingRegisterABI(y toobig, z toobig) toobig {
return toobig{x.a, y.b, z.c}
}
type AnInterface interface {
MagicMethodNameForTestingRegisterABI(y toobig, z toobig) toobig
}
//go:registerparams
//go:noinline
func I(a,b,c string) toobig {
return toobig{a,b,c}
}
// AnIid prevents the compiler from figuring out what the interface really is.
//go:noinline
func AnIid(x AnInterface) AnInterface {
return x
}
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)
fmt.Println(tmp.a, tmp.b, tmp.c)
tmp = AnIid(&x).MagicMethodNameForTestingRegisterABI(y,z)
fmt.Println(tmp.a, tmp.b, tmp.c)
}