Source file test/abi/result_regalloc.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  // Bug: in (*bb).d, the value to be returned was not allocated to
     8  // a register that satisfies its register mask.
     9  
    10  package main
    11  
    12  type bb struct {
    13  	r float64
    14  	x []float64
    15  }
    16  
    17  //go:noinline
    18  func B(r float64, x []float64) I {
    19  	return bb{r, x}
    20  }
    21  
    22  func (b bb) d() (int, int) {
    23  	if b.r == 0 {
    24  		return 0, len(b.x)
    25  	}
    26  	return len(b.x), len(b.x)
    27  }
    28  
    29  type I interface { d() (int, int) }
    30  
    31  func D(r I) (int, int) { return r.d() }
    32  
    33  //go:noinline
    34  func F() (int, int) {
    35  	r := float64(1)
    36  	x := []float64{0, 1, 2}
    37  	b := B(r, x)
    38  	return D(b)
    39  }
    40  
    41  func main() {
    42  	x, y := F()
    43  	if x != 3 || y != 3 {
    44  		panic("FAIL")
    45  	}
    46  }
    47  

View as plain text