Source file test/abi/spills4.go

     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  // wasm is excluded because the compiler chatter about register abi pragma ends up
    10  // on stdout, and causes the expected output to not match.
    11  
    12  package main
    13  
    14  import "fmt"
    15  
    16  type i5f5 struct {
    17  	a, b          int16
    18  	c, d, e       int32
    19  	r, s, t, u, v float32
    20  }
    21  
    22  //go:noinline
    23  func spills(_ *float32) {
    24  
    25  }
    26  
    27  //go:registerparams
    28  //go:noinline
    29  func F(x i5f5) i5f5 {
    30  	y := x.v
    31  	spills(&y)
    32  	x.r = y
    33  	return x
    34  }
    35  
    36  func main() {
    37  	x := i5f5{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
    38  	y := x
    39  	z := F(x)
    40  	if (i5f5{1, 2, 3, 4, 5, 10, 7, 8, 9, 10}) != z {
    41  		fmt.Printf("y=%v, z=%v\n", y, z)
    42  	}
    43  }
    44  

View as plain text