| 1 |
// run |
| 2 |
|
| 3 |
//go:build !wasm |
| 4 |
|
| 5 |
// Copyright 2021 The Go Authors. All rights reserved. |
| 6 |
// Use of this source code is governed by a BSD-style |
| 7 |
// license that can be found in the LICENSE file. |
| 8 |
|
| 9 |
package main |
| 10 |
|
| 11 |
import "fmt" |
| 12 |
|
| 13 |
// Test that register results are correctly returned (and passed) |
| 14 |
|
| 15 |
//go:registerparams |
| 16 |
//go:noinline |
| 17 |
func f(x int) (int, int) { |
| 18 |
|
| 19 |
if x < 3 { |
| 20 |
return 0, x |
| 21 |
} |
| 22 |
|
| 23 |
a, b := f(x - 2) |
| 24 |
c, d := f(x - 1) |
| 25 |
return a + d, b + c |
| 26 |
} |
| 27 |
|
| 28 |
func main() { |
| 29 |
x := 40 |
| 30 |
a, b := f(x) |
| 31 |
fmt.Printf("f(%d)=%d,%d\n", x, a, b) |
| 32 |
} |