Debian Codegraph @

test/codegen/issue52635.go

raw
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 // amd64:-".*runtime.memclrNoHeapPointers"
20 // amd64:`MOVUPS X15,`
21 for i := range t.a {
22 t.a[i] = 0
23 }
24
25 // amd64:-".*runtime.memclrNoHeapPointers"
26 // amd64:`MOVUPS X15,`
27 for i := range *t.a {
28 t.a[i] = 0
29 }
30
31 // amd64:-".*runtime.memclrNoHeapPointers"
32 // amd64:`MOVUPS X15,`
33 for i := range t.a {
34 (*t.a)[i] = 0
35 }
36
37 // amd64:-".*runtime.memclrNoHeapPointers"
38 // amd64:`MOVUPS X15,`
39 for i := range *t.a {
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 }