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  }
    16  
    17  func (t *T) f() {
    18  	// amd64:-".*runtime.memclrNoHeapPointers"
    19  	// amd64:"DUFFZERO"
    20  	for i := range t.a {
    21  		t.a[i] = 0
    22  	}
    23  
    24  	// amd64:-".*runtime.memclrNoHeapPointers"
    25  	// amd64:"DUFFZERO"
    26  	for i := range *t.a {
    27  		t.a[i] = 0
    28  	}
    29  
    30  	// amd64:-".*runtime.memclrNoHeapPointers"
    31  	// amd64:"DUFFZERO"
    32  	for i := range t.a {
    33  		(*t.a)[i] = 0
    34  	}
    35  
    36  	// amd64:-".*runtime.memclrNoHeapPointers"
    37  	// amd64:"DUFFZERO"
    38  	for i := range *t.a {
    39  		(*t.a)[i] = 0
    40  	}
    41  }
    42  

View as plain text