Source file test/abi/store_reg_args.go

     1  // run
     2  
     3  // Copyright 2021 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // When the function Store an Arg and also use it in another place,
     8  // be sure not to generate duplicated OpArgXXXReg values, which confuses
     9  // the register allocator.
    10  
    11  package main
    12  
    13  //go:noinline
    14  //go:registerparams
    15  func F(x, y float32) {
    16  	if x < 0 {
    17  		panic("FAIL")
    18  	}
    19  	g = [4]float32{x, y, x, y}
    20  }
    21  
    22  var g [4]float32
    23  
    24  func main() {
    25  	F(1, 2)
    26  	if g[0] != 1 || g[1] != 2 || g[2] != 1 || g[3] != 2 {
    27  		panic("FAIL")
    28  	}
    29  }
    30  

View as plain text