mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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:
parent
21ab0128b6
commit
cd55f86b8d
7 changed files with 33 additions and 36 deletions
|
|
@ -11201,15 +11201,12 @@ func rewriteValuegeneric_OpIMake(v *Value) bool {
|
|||
v_1 := v.Args[1]
|
||||
v_0 := v.Args[0]
|
||||
// match: (IMake _typ (StructMake val))
|
||||
// result: (IMake _typ val)
|
||||
// result: imakeOfStructMake(v)
|
||||
for {
|
||||
_typ := v_0
|
||||
if v_1.Op != OpStructMake || len(v_1.Args) != 1 {
|
||||
break
|
||||
}
|
||||
val := v_1.Args[0]
|
||||
v.reset(OpIMake)
|
||||
v.AddArg2(_typ, val)
|
||||
v.copyOf(imakeOfStructMake(v))
|
||||
return true
|
||||
}
|
||||
// match: (IMake _typ (ArrayMake1 val))
|
||||
|
|
@ -32045,10 +32042,10 @@ func rewriteValuegeneric_OpStructSelect(v *Value) bool {
|
|||
v0.AddArg2(v1, mem)
|
||||
return true
|
||||
}
|
||||
// match: (StructSelect [0] (IData x))
|
||||
// match: (StructSelect [_] (IData x))
|
||||
// result: (IData x)
|
||||
for {
|
||||
if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpIData {
|
||||
if v_0.Op != OpIData {
|
||||
break
|
||||
}
|
||||
x := v_0.Args[0]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue