mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/ssa: remove redundant "type:" prefix check
Remove redundant "type:" prefix check on symbol names in isFixedLoad, also refactor some duplicate code into methods. Change-Id: I8358422596eea8c39d1a30a554bd0aae8b570038 Reviewed-on: https://go-review.googlesource.com/c/go/+/701275 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
This commit is contained in:
parent
19cc1022ba
commit
fcb893fc4b
2 changed files with 25 additions and 13 deletions
|
|
@ -2059,12 +2059,12 @@ func isFixedLoad(v *Value, sym Sym, off int64) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(lsym.Name, "type:") {
|
if ti := lsym.TypeInfo(); ti != nil {
|
||||||
// Type symbols do not contain information about their fields, unlike the cases above.
|
// Type symbols do not contain information about their fields, unlike the cases above.
|
||||||
// Hand-implement field accesses.
|
// Hand-implement field accesses.
|
||||||
// TODO: can this be replaced with reflectdata.writeType and just use the code above?
|
// TODO: can this be replaced with reflectdata.writeType and just use the code above?
|
||||||
|
|
||||||
t := (*lsym.Extra).(*obj.TypeInfo).Type.(*types.Type)
|
t := ti.Type.(*types.Type)
|
||||||
|
|
||||||
for _, f := range rttype.Type.Fields() {
|
for _, f := range rttype.Type.Fields() {
|
||||||
if f.Offset == off && copyCompatibleType(v.Type, f.Type) {
|
if f.Offset == off && copyCompatibleType(v.Type, f.Type) {
|
||||||
|
|
@ -2118,12 +2118,12 @@ func rewriteFixedLoad(v *Value, sym Sym, sb *Value, off int64) *Value {
|
||||||
base.Fatalf("fixedLoad data not known for %s:%d", sym, off)
|
base.Fatalf("fixedLoad data not known for %s:%d", sym, off)
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(lsym.Name, "type:") {
|
if ti := lsym.TypeInfo(); ti != nil {
|
||||||
// Type symbols do not contain information about their fields, unlike the cases above.
|
// Type symbols do not contain information about their fields, unlike the cases above.
|
||||||
// Hand-implement field accesses.
|
// Hand-implement field accesses.
|
||||||
// TODO: can this be replaced with reflectdata.writeType and just use the code above?
|
// TODO: can this be replaced with reflectdata.writeType and just use the code above?
|
||||||
|
|
||||||
t := (*lsym.Extra).(*obj.TypeInfo).Type.(*types.Type)
|
t := ti.Type.(*types.Type)
|
||||||
|
|
||||||
ptrSizedOpConst := OpConst64
|
ptrSizedOpConst := OpConst64
|
||||||
if f.Config.PtrSize == 4 {
|
if f.Config.PtrSize == 4 {
|
||||||
|
|
@ -2613,10 +2613,7 @@ func isDirectType1(v *Value) bool {
|
||||||
return isDirectType2(v.Args[0])
|
return isDirectType2(v.Args[0])
|
||||||
case OpAddr:
|
case OpAddr:
|
||||||
lsym := v.Aux.(*obj.LSym)
|
lsym := v.Aux.(*obj.LSym)
|
||||||
if lsym.Extra == nil {
|
if ti := lsym.TypeInfo(); ti != nil {
|
||||||
return false
|
|
||||||
}
|
|
||||||
if ti, ok := (*lsym.Extra).(*obj.TypeInfo); ok {
|
|
||||||
return types.IsDirectIface(ti.Type.(*types.Type))
|
return types.IsDirectIface(ti.Type.(*types.Type))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2649,10 +2646,7 @@ func isDirectIface1(v *Value, depth int) bool {
|
||||||
return isDirectIface2(v.Args[0], depth-1)
|
return isDirectIface2(v.Args[0], depth-1)
|
||||||
case OpAddr:
|
case OpAddr:
|
||||||
lsym := v.Aux.(*obj.LSym)
|
lsym := v.Aux.(*obj.LSym)
|
||||||
if lsym.Extra == nil {
|
if ii := lsym.ItabInfo(); ii != nil {
|
||||||
return false
|
|
||||||
}
|
|
||||||
if ii, ok := (*lsym.Extra).(*obj.ItabInfo); ok {
|
|
||||||
return types.IsDirectIface(ii.Type.(*types.Type))
|
return types.IsDirectIface(ii.Type.(*types.Type))
|
||||||
}
|
}
|
||||||
case OpConstNil:
|
case OpConstNil:
|
||||||
|
|
|
||||||
|
|
@ -464,7 +464,7 @@ type LSym struct {
|
||||||
P []byte
|
P []byte
|
||||||
R []Reloc
|
R []Reloc
|
||||||
|
|
||||||
Extra *interface{} // *FuncInfo, *VarInfo, *FileInfo, or *TypeInfo, if present
|
Extra *interface{} // *FuncInfo, *VarInfo, *FileInfo, *TypeInfo, or *ItabInfo, if present
|
||||||
|
|
||||||
Pkg string
|
Pkg string
|
||||||
PkgIdx int32
|
PkgIdx int32
|
||||||
|
|
@ -604,6 +604,15 @@ func (s *LSym) NewTypeInfo() *TypeInfo {
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TypeInfo returns the *TypeInfo associated with s, or else nil.
|
||||||
|
func (s *LSym) TypeInfo() *TypeInfo {
|
||||||
|
if s.Extra == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t, _ := (*s.Extra).(*TypeInfo)
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
// An ItabInfo contains information for a symbol
|
// An ItabInfo contains information for a symbol
|
||||||
// that contains a runtime.itab.
|
// that contains a runtime.itab.
|
||||||
type ItabInfo struct {
|
type ItabInfo struct {
|
||||||
|
|
@ -620,6 +629,15 @@ func (s *LSym) NewItabInfo() *ItabInfo {
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ItabInfo returns the *ItabInfo associated with s, or else nil.
|
||||||
|
func (s *LSym) ItabInfo() *ItabInfo {
|
||||||
|
if s.Extra == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
i, _ := (*s.Extra).(*ItabInfo)
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
// WasmImport represents a WebAssembly (WASM) imported function with
|
// WasmImport represents a WebAssembly (WASM) imported function with
|
||||||
// parameters and results translated into WASM types based on the Go function
|
// parameters and results translated into WASM types based on the Go function
|
||||||
// declaration.
|
// declaration.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue