Skip to content

Commit ea50d61

Browse files
randall77gopherbot
authored andcommitted
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>
1 parent bd4dc41 commit ea50d61

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/cmd/compile/internal/ssa/_gen/generic.rules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2927,15 +2927,15 @@
29272927
// we know the underlying type is pointer-ish.
29282928
(StaticLECall {f} typ_ x y mem)
29292929
&& isSameCall(f, "runtime.efaceeq")
2930-
&& isDirectType(typ_)
2930+
&& isDirectAndComparableType(typ_)
29312931
&& clobber(v)
29322932
=> (MakeResult (EqPtr x y) mem)
29332933

29342934
// We can easily compute the result of ifaceeq if
29352935
// we know the underlying type is pointer-ish.
29362936
(StaticLECall {f} itab x y mem)
29372937
&& isSameCall(f, "runtime.ifaceeq")
2938-
&& isDirectIface(itab)
2938+
&& isDirectAndComparableIface(itab)
29392939
&& clobber(v)
29402940
=> (MakeResult (EqPtr x y) mem)
29412941

src/cmd/compile/internal/ssa/rewrite.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,18 +2624,18 @@ func rewriteStructStore(v *Value) *Value {
26242624
return mem
26252625
}
26262626

2627-
// isDirectType reports whether v represents a type
2627+
// isDirectAndComparableType reports whether v represents a type
26282628
// (a *runtime._type) whose value is stored directly in an
26292629
// interface (i.e., is pointer or pointer-like) and is comparable.
2630-
func isDirectType(v *Value) bool {
2631-
return isDirectType1(v)
2630+
func isDirectAndComparableType(v *Value) bool {
2631+
return isDirectAndComparableType1(v)
26322632
}
26332633

26342634
// v is a type
2635-
func isDirectType1(v *Value) bool {
2635+
func isDirectAndComparableType1(v *Value) bool {
26362636
switch v.Op {
26372637
case OpITab:
2638-
return isDirectType2(v.Args[0])
2638+
return isDirectAndComparableType2(v.Args[0])
26392639
case OpAddr:
26402640
lsym := v.Aux.(*obj.LSym)
26412641
if ti := lsym.TypeInfo(); ti != nil {
@@ -2647,29 +2647,29 @@ func isDirectType1(v *Value) bool {
26472647
}
26482648

26492649
// v is an empty interface
2650-
func isDirectType2(v *Value) bool {
2650+
func isDirectAndComparableType2(v *Value) bool {
26512651
switch v.Op {
26522652
case OpIMake:
2653-
return isDirectType1(v.Args[0])
2653+
return isDirectAndComparableType1(v.Args[0])
26542654
}
26552655
return false
26562656
}
26572657

2658-
// isDirectIface reports whether v represents an itab
2658+
// isDirectAndComparableIface reports whether v represents an itab
26592659
// (a *runtime._itab) for a type whose value is stored directly
26602660
// in an interface (i.e., is pointer or pointer-like) and is comparable.
2661-
func isDirectIface(v *Value) bool {
2662-
return isDirectIface1(v, 9)
2661+
func isDirectAndComparableIface(v *Value) bool {
2662+
return isDirectAndComparableIface1(v, 9)
26632663
}
26642664

26652665
// v is an itab
2666-
func isDirectIface1(v *Value, depth int) bool {
2666+
func isDirectAndComparableIface1(v *Value, depth int) bool {
26672667
if depth == 0 {
26682668
return false
26692669
}
26702670
switch v.Op {
26712671
case OpITab:
2672-
return isDirectIface2(v.Args[0], depth-1)
2672+
return isDirectAndComparableIface2(v.Args[0], depth-1)
26732673
case OpAddr:
26742674
lsym := v.Aux.(*obj.LSym)
26752675
if ii := lsym.ItabInfo(); ii != nil {
@@ -2685,16 +2685,16 @@ func isDirectIface1(v *Value, depth int) bool {
26852685
}
26862686

26872687
// v is an interface
2688-
func isDirectIface2(v *Value, depth int) bool {
2688+
func isDirectAndComparableIface2(v *Value, depth int) bool {
26892689
if depth == 0 {
26902690
return false
26912691
}
26922692
switch v.Op {
26932693
case OpIMake:
2694-
return isDirectIface1(v.Args[0], depth-1)
2694+
return isDirectAndComparableIface1(v.Args[0], depth-1)
26952695
case OpPhi:
26962696
for _, a := range v.Args {
2697-
if !isDirectIface2(a, depth-1) {
2697+
if !isDirectAndComparableIface2(a, depth-1) {
26982698
return false
26992699
}
27002700
}

src/cmd/compile/internal/ssa/rewritegeneric.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)