mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: name change isDirect -> isDirectAndComparable
Now that it also restricts to comparable types. Followon to CL 713840. Change-Id: Idd975c3fd16fb51f55360f2fa0b89ab0bf1d00ed Reviewed-on: https://go-review.googlesource.com/c/go/+/715700 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
bd4dc413cd
commit
ea50d61b66
3 changed files with 21 additions and 21 deletions
|
|
@ -2927,7 +2927,7 @@
|
||||||
// we know the underlying type is pointer-ish.
|
// we know the underlying type is pointer-ish.
|
||||||
(StaticLECall {f} typ_ x y mem)
|
(StaticLECall {f} typ_ x y mem)
|
||||||
&& isSameCall(f, "runtime.efaceeq")
|
&& isSameCall(f, "runtime.efaceeq")
|
||||||
&& isDirectType(typ_)
|
&& isDirectAndComparableType(typ_)
|
||||||
&& clobber(v)
|
&& clobber(v)
|
||||||
=> (MakeResult (EqPtr x y) mem)
|
=> (MakeResult (EqPtr x y) mem)
|
||||||
|
|
||||||
|
|
@ -2935,7 +2935,7 @@
|
||||||
// we know the underlying type is pointer-ish.
|
// we know the underlying type is pointer-ish.
|
||||||
(StaticLECall {f} itab x y mem)
|
(StaticLECall {f} itab x y mem)
|
||||||
&& isSameCall(f, "runtime.ifaceeq")
|
&& isSameCall(f, "runtime.ifaceeq")
|
||||||
&& isDirectIface(itab)
|
&& isDirectAndComparableIface(itab)
|
||||||
&& clobber(v)
|
&& clobber(v)
|
||||||
=> (MakeResult (EqPtr x y) mem)
|
=> (MakeResult (EqPtr x y) mem)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2624,18 +2624,18 @@ func rewriteStructStore(v *Value) *Value {
|
||||||
return mem
|
return mem
|
||||||
}
|
}
|
||||||
|
|
||||||
// isDirectType reports whether v represents a type
|
// isDirectAndComparableType reports whether v represents a type
|
||||||
// (a *runtime._type) whose value is stored directly in an
|
// (a *runtime._type) whose value is stored directly in an
|
||||||
// interface (i.e., is pointer or pointer-like) and is comparable.
|
// interface (i.e., is pointer or pointer-like) and is comparable.
|
||||||
func isDirectType(v *Value) bool {
|
func isDirectAndComparableType(v *Value) bool {
|
||||||
return isDirectType1(v)
|
return isDirectAndComparableType1(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// v is a type
|
// v is a type
|
||||||
func isDirectType1(v *Value) bool {
|
func isDirectAndComparableType1(v *Value) bool {
|
||||||
switch v.Op {
|
switch v.Op {
|
||||||
case OpITab:
|
case OpITab:
|
||||||
return isDirectType2(v.Args[0])
|
return isDirectAndComparableType2(v.Args[0])
|
||||||
case OpAddr:
|
case OpAddr:
|
||||||
lsym := v.Aux.(*obj.LSym)
|
lsym := v.Aux.(*obj.LSym)
|
||||||
if ti := lsym.TypeInfo(); ti != nil {
|
if ti := lsym.TypeInfo(); ti != nil {
|
||||||
|
|
@ -2647,29 +2647,29 @@ func isDirectType1(v *Value) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// v is an empty interface
|
// v is an empty interface
|
||||||
func isDirectType2(v *Value) bool {
|
func isDirectAndComparableType2(v *Value) bool {
|
||||||
switch v.Op {
|
switch v.Op {
|
||||||
case OpIMake:
|
case OpIMake:
|
||||||
return isDirectType1(v.Args[0])
|
return isDirectAndComparableType1(v.Args[0])
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// isDirectIface reports whether v represents an itab
|
// isDirectAndComparableIface reports whether v represents an itab
|
||||||
// (a *runtime._itab) for a type whose value is stored directly
|
// (a *runtime._itab) for a type whose value is stored directly
|
||||||
// in an interface (i.e., is pointer or pointer-like) and is comparable.
|
// in an interface (i.e., is pointer or pointer-like) and is comparable.
|
||||||
func isDirectIface(v *Value) bool {
|
func isDirectAndComparableIface(v *Value) bool {
|
||||||
return isDirectIface1(v, 9)
|
return isDirectAndComparableIface1(v, 9)
|
||||||
}
|
}
|
||||||
|
|
||||||
// v is an itab
|
// v is an itab
|
||||||
func isDirectIface1(v *Value, depth int) bool {
|
func isDirectAndComparableIface1(v *Value, depth int) bool {
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
switch v.Op {
|
switch v.Op {
|
||||||
case OpITab:
|
case OpITab:
|
||||||
return isDirectIface2(v.Args[0], depth-1)
|
return isDirectAndComparableIface2(v.Args[0], depth-1)
|
||||||
case OpAddr:
|
case OpAddr:
|
||||||
lsym := v.Aux.(*obj.LSym)
|
lsym := v.Aux.(*obj.LSym)
|
||||||
if ii := lsym.ItabInfo(); ii != nil {
|
if ii := lsym.ItabInfo(); ii != nil {
|
||||||
|
|
@ -2685,16 +2685,16 @@ func isDirectIface1(v *Value, depth int) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// v is an interface
|
// v is an interface
|
||||||
func isDirectIface2(v *Value, depth int) bool {
|
func isDirectAndComparableIface2(v *Value, depth int) bool {
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
switch v.Op {
|
switch v.Op {
|
||||||
case OpIMake:
|
case OpIMake:
|
||||||
return isDirectIface1(v.Args[0], depth-1)
|
return isDirectAndComparableIface1(v.Args[0], depth-1)
|
||||||
case OpPhi:
|
case OpPhi:
|
||||||
for _, a := range v.Args {
|
for _, a := range v.Args {
|
||||||
if !isDirectIface2(a, depth-1) {
|
if !isDirectAndComparableIface2(a, depth-1) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32612,7 +32612,7 @@ func rewriteValuegeneric_OpStaticLECall(v *Value) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// match: (StaticLECall {f} typ_ x y mem)
|
// match: (StaticLECall {f} typ_ x y mem)
|
||||||
// cond: isSameCall(f, "runtime.efaceeq") && isDirectType(typ_) && clobber(v)
|
// cond: isSameCall(f, "runtime.efaceeq") && isDirectAndComparableType(typ_) && clobber(v)
|
||||||
// result: (MakeResult (EqPtr x y) mem)
|
// result: (MakeResult (EqPtr x y) mem)
|
||||||
for {
|
for {
|
||||||
if len(v.Args) != 4 {
|
if len(v.Args) != 4 {
|
||||||
|
|
@ -32623,7 +32623,7 @@ func rewriteValuegeneric_OpStaticLECall(v *Value) bool {
|
||||||
typ_ := v.Args[0]
|
typ_ := v.Args[0]
|
||||||
x := v.Args[1]
|
x := v.Args[1]
|
||||||
y := v.Args[2]
|
y := v.Args[2]
|
||||||
if !(isSameCall(f, "runtime.efaceeq") && isDirectType(typ_) && clobber(v)) {
|
if !(isSameCall(f, "runtime.efaceeq") && isDirectAndComparableType(typ_) && clobber(v)) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
v.reset(OpMakeResult)
|
v.reset(OpMakeResult)
|
||||||
|
|
@ -32633,7 +32633,7 @@ func rewriteValuegeneric_OpStaticLECall(v *Value) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// match: (StaticLECall {f} itab x y mem)
|
// match: (StaticLECall {f} itab x y mem)
|
||||||
// cond: isSameCall(f, "runtime.ifaceeq") && isDirectIface(itab) && clobber(v)
|
// cond: isSameCall(f, "runtime.ifaceeq") && isDirectAndComparableIface(itab) && clobber(v)
|
||||||
// result: (MakeResult (EqPtr x y) mem)
|
// result: (MakeResult (EqPtr x y) mem)
|
||||||
for {
|
for {
|
||||||
if len(v.Args) != 4 {
|
if len(v.Args) != 4 {
|
||||||
|
|
@ -32644,7 +32644,7 @@ func rewriteValuegeneric_OpStaticLECall(v *Value) bool {
|
||||||
itab := v.Args[0]
|
itab := v.Args[0]
|
||||||
x := v.Args[1]
|
x := v.Args[1]
|
||||||
y := v.Args[2]
|
y := v.Args[2]
|
||||||
if !(isSameCall(f, "runtime.ifaceeq") && isDirectIface(itab) && clobber(v)) {
|
if !(isSameCall(f, "runtime.ifaceeq") && isDirectAndComparableIface(itab) && clobber(v)) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
v.reset(OpMakeResult)
|
v.reset(OpMakeResult)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue