• Austin Clements's avatar
    cmd/compile: omit write barriers for slice clears of go:notinheap pointers · 6454a09a
    Austin Clements authored
    Currently,
    
      for i := range a {
        a[i] = nil
      }
    
    will compile to have write barriers even if a is a slice of pointers
    to go:notinheap types. This happens because the optimization that
    transforms this into a memclr only asks it a's element type has
    pointers, and not if it specifically has heap pointers.
    
    Fix this by changing arrayClear to use HasHeapPointer instead of
    types.Haspointers. We probably shouldn't have both of these functions,
    since a pointer to a notinheap type is effectively a uintptr, but
    that's not going to change in this CL.
    
    Change-Id: I284b85bdec6ae1e641f894e8f577989facdb0cf1
    Reviewed-on: https://go-review.googlesource.com/c/152723
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
    6454a09a