github.com/GoWebProd/gip@v0.0.0-20230623090727-b60d41d5d320/rtime/noescape.go (about) 1 package rtime 2 3 import "unsafe" 4 5 // noescape hides a pointer from escape analysis. noescape is 6 // the identity function but escape analysis doesn't think the 7 // output depends on the input. noescape is inlined and currently 8 // compiles down to zero instructions. 9 // USE CAREFULLY! 10 //go:nosplit 11 func Noescape[T any](p *T) unsafe.Pointer { 12 x := uintptr(unsafe.Pointer(p)) 13 return unsafe.Pointer(x ^ 0) 14 }