github.com/ssgreg/logf@v1.4.1/noescape.go (about)

     1  package logf
     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(p unsafe.Pointer) unsafe.Pointer {
    12  	x := uintptr(p)
    13  
    14  	return unsafe.Pointer(x ^ 0)
    15  }