// noescape hides a pointer from escape analysis. noescape is
// the identity function but escape analysis doesn't think the
// output depends on the input. noescape is inlined and currently
// compiles down to zero instructions.
// USE CAREFULLY!
//go:nosplit
func noescape(p unsafe.Pointer) unsafe.Pointer {
x := uintptr(p)
return unsafe.Pointer(x ^ 0)
}
To the original poster: are you just curious why, or is there a more specific question you have? I'm assuming that function looks like that to correctly trick the compiler; perhaps escape analysis gives up if you start xor-ing uintptr values or something like that.