Source file test/codegen/alloc.go

     1  // asmcheck
     2  
     3  // Copyright 2018 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  // These tests check that allocating a 0-size object does not
     8  // introduce a call to runtime.newobject.
     9  
    10  package codegen
    11  
    12  func zeroAllocNew1() *struct{} {
    13  	// 386:-`CALL\truntime\.newobject`
    14  	// amd64:-`CALL\truntime\.newobject`
    15  	// arm:-`CALL\truntime\.newobject`
    16  	// arm64:-`CALL\truntime\.newobject`
    17  	return new(struct{})
    18  }
    19  
    20  func zeroAllocNew2() *[0]int {
    21  	// 386:-`CALL\truntime\.newobject`
    22  	// amd64:-`CALL\truntime\.newobject`
    23  	// arm:-`CALL\truntime\.newobject`
    24  	// arm64:-`CALL\truntime\.newobject`
    25  	return new([0]int)
    26  }
    27  
    28  func zeroAllocSliceLit() []int {
    29  	// 386:-`CALL\truntime\.newobject`
    30  	// amd64:-`CALL\truntime\.newobject`
    31  	// arm:-`CALL\truntime\.newobject`
    32  	// arm64:-`CALL\truntime\.newobject`
    33  	return []int{}
    34  }
    35  

View as plain text