3 // Copyright 2019 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.
7 // Test escape analysis for runtime/internal/atomic.
12 "runtime/internal/atomic"
16 // BAD: should always be "leaking param: addr to result ~r0 level=1$".
17 func Loadp(addr unsafe.Pointer) unsafe.Pointer { // ERROR "leaking param: addr( to result ~r0 level=1)?$"
18 return atomic.Loadp(addr)
21 var ptr unsafe.Pointer
24 var x int // ERROR "moved to heap: x"
25 atomic.StorepNoWB(unsafe.Pointer(&ptr), unsafe.Pointer(&x))
29 // BAD: should always be "does not escape"
30 x := new(int) // ERROR "escapes to heap|does not escape"
31 var y int // ERROR "moved to heap: y"
32 atomic.Casp1(&ptr, unsafe.Pointer(x), unsafe.Pointer(&y))