cmd/compile: allow multi-field structs to be stored directly in interfaces

If the struct is a bunch of 0-sized fields and one pointer field.

Fixes #74092

Change-Id: I87c5d162c8c9fdba812420d7f9d21de97295b62c
Reviewed-on: https://go-review.googlesource.com/c/go/+/681937
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
This commit is contained in:
Keith Randall 2025-06-14 20:10:50 -07:00
parent 21ab0128b6
commit cd55f86b8d
7 changed files with 33 additions and 36 deletions

View file

@ -2689,3 +2689,17 @@ func panicBoundsCToAux(p PanicBoundsC) Aux {
func panicBoundsCCToAux(p PanicBoundsCC) Aux {
return p
}
// When v is (IMake typ (StructMake ...)), convert to
// (IMake typ arg) where arg is the pointer-y argument to
// the StructMake (there must be exactly one).
func imakeOfStructMake(v *Value) *Value {
var arg *Value
for _, a := range v.Args[1].Args {
if a.Type.Size() > 0 {
arg = a
break
}
}
return v.Block.NewValue2(v.Pos, OpIMake, v.Type, v.Args[0], arg)
}