cmd/compile: rename Type.IsPtr to Type.IsPtrShaped
Previously, t.IsPtr() reported whether t was represented with a
pointer, but some of its callers expected it to report whether t is an
actual Go pointer. Resolve this by renaming t.IsPtr to t.IsPtrShaped
and adding a new t.IsPtr method to report Go pointer types.
Updated a couple callers in gc/ssa.go to use IsPtr instead of
IsPtrShaped.
Passes toolstash -cmp.
Updates #15028.
Change-Id: I0a8154b5822ad8a6ad296419126ad01a3d2a5dc5
Reviewed-on: https://go-review.googlesource.com/21232
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go
index 3eb462e..11a478a 100644
--- a/src/cmd/compile/internal/gc/ssa.go
+++ b/src/cmd/compile/internal/gc/ssa.go
@@ -1512,14 +1512,14 @@
// We don't want pointers accidentally classified
// as not-pointers or vice-versa because of copy
// elision.
- if to.IsPtr() != from.IsPtr() {
+ if to.IsPtrShaped() != from.IsPtrShaped() {
return s.newValue2(ssa.OpConvert, to, x, s.mem())
}
v := s.newValue1(ssa.OpCopy, to, x) // ensure that v has the right type
// CONVNOP closure
- if to.Etype == TFUNC && from.IsPtr() {
+ if to.Etype == TFUNC && from.IsPtrShaped() {
return v
}
@@ -1999,7 +1999,7 @@
// So here we ensure that we are selecting the underlying pointer
// when we build an eface.
// TODO: get rid of this now that structs can be SSA'd?
- for !data.Type.IsPtr() {
+ for !data.Type.IsPtrShaped() {
switch {
case data.Type.IsArray():
data = s.newValue1I(ssa.OpArrayIndex, data.Type.ElemType(), 0, data)
@@ -2351,7 +2351,7 @@
case t.IsString():
return s.constEmptyString(t)
- case t.IsPtr():
+ case t.IsPtrShaped():
return s.constNil(t)
case t.IsBoolean():
return s.constBool(false)
@@ -3026,7 +3026,7 @@
switch {
case t.IsBoolean() || t.IsInteger() || t.IsFloat() || t.IsComplex():
s.vars[&memVar] = s.newValue3I(ssa.OpStore, ssa.TypeMem, t.Size(), left, right, s.mem())
- case t.IsPtr() || t.IsMap() || t.IsChan():
+ case t.IsPtrShaped():
// no scalar fields.
case t.IsString():
if skip&skipLen != 0 {
@@ -3066,7 +3066,7 @@
// do *left = right for all pointer parts of t.
func (s *state) storeTypePtrs(t *Type, left, right *ssa.Value) {
switch {
- case t.IsPtr() || t.IsMap() || t.IsChan():
+ case t.IsPtrShaped():
s.vars[&memVar] = s.newValue3I(ssa.OpStore, ssa.TypeMem, s.config.PtrSize, left, right, s.mem())
case t.IsString():
ptr := s.newValue1(ssa.OpStringPtr, Ptrto(Types[TUINT8]), right)
@@ -3098,7 +3098,7 @@
// do *left = right with a write barrier for all pointer parts of t.
func (s *state) storeTypePtrsWB(t *Type, left, right *ssa.Value) {
switch {
- case t.IsPtr() || t.IsMap() || t.IsChan():
+ case t.IsPtrShaped():
s.rtcall(writebarrierptr, true, nil, left, right)
case t.IsString():
ptr := s.newValue1(ssa.OpStringPtr, Ptrto(Types[TUINT8]), right)