Revert "cmd/compile: allow StructSelect [x] of interface data fields for x>0"

This reverts commit bcd25c79aa (CL 693415)

Reason for revert: still causing compiler failures on Google test code

Change-Id: I887edcff56bde3ffa316f2b629021ad323a357fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/694996
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Keith Randall 2025-08-11 17:31:03 -07:00
parent 7248995b60
commit c31359138c
3 changed files with 8 additions and 25 deletions

View file

@ -98,7 +98,7 @@
// Some of these are copied from generic.rules // Some of these are copied from generic.rules
(IMake _typ (StructMake val)) => (IMake _typ val) (IMake _typ (StructMake val)) => (IMake _typ val)
(StructSelect (IData x)) => (IData x) (StructSelect [0] (IData x)) => (IData x)
(StructSelect [i] x:(StructMake ___)) => x.Args[i] (StructSelect [i] x:(StructMake ___)) => x.Args[i]
@ -109,7 +109,7 @@
// More annoying case: (ArraySelect[0] (StructSelect[0] isAPtr)) // More annoying case: (ArraySelect[0] (StructSelect[0] isAPtr))
// There, result of the StructSelect is an Array (not a pointer) and // There, result of the StructSelect is an Array (not a pointer) and
// the pre-rewrite input to the ArraySelect is a struct, not a pointer. // the pre-rewrite input to the ArraySelect is a struct, not a pointer.
(StructSelect x) && x.Type.IsPtrShaped() => x (StructSelect [0] x) && x.Type.IsPtrShaped() => x
(ArraySelect [0] x) && x.Type.IsPtrShaped() => x (ArraySelect [0] x) && x.Type.IsPtrShaped() => x
// These, too. Bits is bits. // These, too. Bits is bits.

View file

@ -839,10 +839,10 @@ func rewriteValuedec_OpStructMake(v *Value) bool {
func rewriteValuedec_OpStructSelect(v *Value) bool { func rewriteValuedec_OpStructSelect(v *Value) bool {
v_0 := v.Args[0] v_0 := v.Args[0]
b := v.Block b := v.Block
// match: (StructSelect (IData x)) // match: (StructSelect [0] (IData x))
// result: (IData x) // result: (IData x)
for { for {
if v_0.Op != OpIData { if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpIData {
break break
} }
x := v_0.Args[0] x := v_0.Args[0]
@ -861,10 +861,13 @@ func rewriteValuedec_OpStructSelect(v *Value) bool {
v.copyOf(x.Args[i]) v.copyOf(x.Args[i])
return true return true
} }
// match: (StructSelect x) // match: (StructSelect [0] x)
// cond: x.Type.IsPtrShaped() // cond: x.Type.IsPtrShaped()
// result: x // result: x
for { for {
if auxIntToInt64(v.AuxInt) != 0 {
break
}
x := v_0 x := v_0
if !(x.Type.IsPtrShaped()) { if !(x.Type.IsPtrShaped()) {
break break

View file

@ -1,20 +0,0 @@
// compile
// Copyright 2025 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 main
type P struct {
q struct{}
p *int
}
func f(x any) {
h(x.(P))
}
//go:noinline
func h(P) {
}