Do the meaning of these three types of outputs have detailed explanation?
Or is there a document or design document about escape analysis?
Thank you!
```
escapes to heap
leaking param
moved to heap
```
According to my test result,
`moved to heap` is allocated on the heap,
The other two are not always on the heap.
>You can think of escapes to heap as a debug message, it does not indicate that one of your variables is "relocated" to the heap.
So the other two are debug messages?
Only `moved to heap` is the definite result?
my examples:
```
package main
import (
"fmt"
"unsafe"
)
//go:linkname inheap runtime.inheap
func inheap(b uintptr) bool
func f0_0() {
var x int
f0_1(&x)
}
func f0_1(a *int) { // a does not escape
println("f0_1:a", inheap(uintptr(unsafe.Pointer(&a)))) // f0_1:a false
}
func f1_0() {
var x int
f1_1(&x)
}
func f1_1(a *int) {
fmt.Println(a) // leaking param: a
println("f1_1:a", inheap(uintptr(unsafe.Pointer(&a)))) // f1_1:a false
}
var global1 *int
var global2 **int
func f2_0() {
var x int
f2_1(&x)
}
func f2_1(a *int) {
global1 = a // leaking param: a
println("f2_1:a", inheap(uintptr(unsafe.Pointer(&a)))) // f2_1:a false
}
func f3_0() {
var x int
f3_1(&x)
}
func f3_1(a *int) {
global2 = &a // moved to heap: a
println("f3_1:a", inheap(uintptr(unsafe.Pointer(&a)))) // f3_1:a true
}
func f4_0() {
var x int
f4_1(x)
}
func f4_1(a int) {
fmt.Println(a) // a escapes to heap
println("f4_1:a", inheap(uintptr(unsafe.Pointer(&a)))) // f4_1:a false
}
func main() {
f0_0()
f1_0()
f2_0()
f3_0()
f4_0()
}
```
You can add `empty.s` and run
```
go build -gcflags='-m'
./XXX
```
to get the result.