Source file test/abi/spills4.go

     1  // run
     2  
     3  //go:build !wasm
     4  // +build !wasm
     5  
     6  // Copyright 2021 The Go Authors. All rights reserved.
     7  // Use of this source code is governed by a BSD-style
     8  // license that can be found in the LICENSE file.
     9  
    10  // wasm is excluded because the compiler chatter about register abi pragma ends up
    11  // on stdout, and causes the expected output to not match.
    12  
    13  package main
    14  
    15  import "fmt"
    16  
    17  type i5f5 struct {
    18  	a, b          int16
    19  	c, d, e       int32
    20  	r, s, t, u, v float32
    21  }
    22  
    23  //go:noinline
    24  func spills(_ *float32) {
    25  
    26  }
    27  
    28  //go:registerparams
    29  //go:noinline
    30  func F(x i5f5) i5f5 {
    31  	y := x.v
    32  	spills(&y)
    33  	x.r = y
    34  	return x
    35  }
    36  
    37  func main() {
    38  	x := i5f5{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
    39  	y := x
    40  	z := F(x)
    41  	if (i5f5{1, 2, 3, 4, 5, 10, 7, 8, 9, 10}) != z {
    42  		fmt.Printf("y=%v, z=%v\n", y, z)
    43  	}
    44  }
    45  

View as plain text