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 runtime\.newobject`, `LEAL runtime.zerobase` 14 // amd64:-`CALL runtime\.newobject`, `LEAQ runtime.zerobase` 15 // arm:-`CALL runtime\.newobject`, `MOVW [$]runtime.zerobase` 16 // arm64:-`CALL runtime\.newobject`, `MOVD [$]runtime.zerobase` 17 // riscv64:-`CALL runtime\.newobject`, `MOV [$]runtime.zerobase` 18 return new(struct{}) 19 } 20 21 func zeroAllocNew2() *[0]int { 22 // 386:-`CALL runtime\.newobject`, `LEAL runtime.zerobase` 23 // amd64:-`CALL runtime\.newobject`, `LEAQ runtime.zerobase` 24 // arm:-`CALL runtime\.newobject`, `MOVW [$]runtime.zerobase` 25 // arm64:-`CALL runtime\.newobject`, `MOVD [$]runtime.zerobase` 26 // riscv64:-`CALL runtime\.newobject`, `MOV [$]runtime.zerobase` 27 return new([0]int) 28 } 29 30 func zeroAllocSliceLit() []int { 31 // 386:-`CALL runtime\.newobject`, `LEAL runtime.zerobase` 32 // amd64:-`CALL runtime\.newobject`, `LEAQ runtime.zerobase` 33 // arm:-`CALL runtime\.newobject`, `MOVW [$]runtime.zerobase` 34 // arm64:-`CALL runtime\.newobject`, `MOVD [$]runtime.zerobase` 35 // riscv64:-`CALL runtime\.newobject`, `MOV [$]runtime.zerobase` 36 return []int{} 37 } 38