1
0
mirror of https://github.com/golang/go synced 2024-11-14 22:50:27 -07:00
go/test/codegen/issue68845.go
Keith Randall b2cdaf7346 cmd/compile: improve unneeded zeroing removal
After newobject, we don't need to write zeroes to initialize the
object.  It has already been zeroed by the allocator.

This is already handled in most cases, but because we run builtin
decomposition after the opt pass, we don't handle cases where the zero
of a compound builtin is being written. Improve the zero detector to
handle those cases.

Fixes #68845

Change-Id: If3dde2e304a05e5a6a6723565191d5444b334bcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/605255
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-08-14 18:16:29 +00:00

53 lines
703 B
Go

// asmcheck
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package codegen
type T1 struct {
x string
}
func f1() *T1 {
// amd64:-`MOVQ\s[$]0`,-`MOVUPS\sX15`
return &T1{}
}
type T2 struct {
x, y string
}
func f2() *T2 {
// amd64:-`MOVQ\s[$]0`,-`MOVUPS\sX15`
return &T2{}
}
type T3 struct {
x complex128
}
func f3() *T3 {
// amd64:-`MOVQ\s[$]0`,-`MOVUPS\sX15`
return &T3{}
}
type T4 struct {
x []byte
}
func f4() *T4 {
// amd64:-`MOVQ\s[$]0`,-`MOVUPS\sX15`
return &T4{}
}
type T5 struct {
x any
}
func f5() *T5 {
// amd64:-`MOVQ\s[$]0`,-`MOVUPS\sX15`
return &T5{}
}