Source file test/codegen/issue52635.go
1 // asmcheck 2 3 // Copyright 2022 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Test that optimized range memclr works with pointers to arrays. 8 // The clears get inlined, see https://github.com/golang/go/issues/56997 9 10 package codegen 11 12 type T struct { 13 a *[10]int 14 b [10]int 15 s []int 16 } 17 18 func (t *T) f() { 19 for i := range t.a { 20 // amd64:-".*runtime.memclrNoHeapPointers" 21 // amd64:`MOVUPS X15,` 22 t.a[i] = 0 23 } 24 25 for i := range *t.a { 26 // amd64:-".*runtime.memclrNoHeapPointers" 27 // amd64:`MOVUPS X15,` 28 t.a[i] = 0 29 } 30 31 for i := range t.a { 32 // amd64:-".*runtime.memclrNoHeapPointers" 33 // amd64:`MOVUPS X15,` 34 (*t.a)[i] = 0 35 } 36 37 for i := range *t.a { 38 // amd64:-".*runtime.memclrNoHeapPointers" 39 // amd64:`MOVUPS X15,` 40 (*t.a)[i] = 0 41 } 42 43 // amd64:-".*runtime.memclrNoHeapPointers" 44 // amd64:`MOVUPS X15,` 45 for i := range t.b { 46 t.b[i] = 0 47 } 48 49 // amd64:".*runtime.memclrNoHeapPointers" 50 for i := range t.s { 51 t.s[i] = 0 52 } 53 } 54