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 func G() (t TI) { 22 t[0] = 1 23 t[1] = 2 24 t[2] = 3 25 runtime.GC() // prevent inlining 26 return 27 } 28 29 func F() (t T) { 30 t.X = newint() 31 t.Y = t.X 32 t.Z = t.Y 33 runtime.GC() // prevent inlining 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