Source file test/fixedbugs/issue8036.go

     1  // run
     2  
     3  // Copyright 2014 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  // Issue 8036. Stores necessary for stack scan being eliminated as redundant by optimizer.
     8  
     9  package main
    10  
    11  import "runtime"
    12  
    13  type T struct {
    14  	X *int
    15  	Y *int
    16  	Z *int
    17  }
    18  
    19  type TI [3]uintptr
    20  
    21  //go:noinline
    22  func G() (t TI) {
    23  	t[0] = 1
    24  	t[1] = 2
    25  	t[2] = 3
    26  	return
    27  }
    28  
    29  //go:noinline
    30  func F() (t T) {
    31  	t.X = newint()
    32  	t.Y = t.X
    33  	t.Z = t.Y
    34  	return
    35  }
    36  
    37  func newint() *int {
    38  	runtime.GC()
    39  	return nil
    40  }
    41  
    42  func main() {
    43  	G() // leave non-pointers where F's return values go
    44  	F()
    45  }
    46  

View as plain text