1
0
mirror of https://github.com/golang/go synced 2024-11-23 07:00:05 -07:00

[dev.regabi] cmd/compile: use LinksymOffsetExpr in TypePtr/ItabAddr

Passes toolstash -cmp.

Fixes #43737

Change-Id: I2d5228c0213b5f8742e3cea6fac9bc985b19d78c
Reviewed-on: https://go-review.googlesource.com/c/go/+/284122
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Cuong Manh Le 2021-01-18 09:42:53 +07:00
parent 0ffa1ead6e
commit 4c835f9169
2 changed files with 9 additions and 26 deletions

View File

@ -836,39 +836,22 @@ func TypeLinksym(t *types.Type) *obj.LSym {
}
func TypePtr(t *types.Type) *ir.AddrExpr {
s := TypeSym(t)
if s.Def == nil {
n := ir.NewNameAt(src.NoXPos, s)
n.SetType(types.Types[types.TUINT8])
n.Class = ir.PEXTERN
n.SetTypecheck(1)
s.Def = n
}
n := typecheck.NodAddr(ir.AsNode(s.Def))
n.SetType(types.NewPtr(s.Def.Type()))
n.SetTypecheck(1)
return n
n := ir.NewLinksymExpr(base.Pos, TypeLinksym(t), types.Types[types.TUINT8])
return typecheck.Expr(typecheck.NodAddr(n)).(*ir.AddrExpr)
}
func ITabAddr(t, itype *types.Type) *ir.AddrExpr {
if t == nil || (t.IsPtr() && t.Elem() == nil) || t.IsUntyped() || !itype.IsInterface() || itype.IsEmptyInterface() {
base.Fatalf("ITabAddr(%v, %v)", t, itype)
}
s := ir.Pkgs.Itab.Lookup(t.ShortString() + "," + itype.ShortString())
if s.Def == nil {
n := typecheck.NewName(s)
n.SetType(types.Types[types.TUINT8])
n.Class = ir.PEXTERN
n.SetTypecheck(1)
s.Def = n
itabs = append(itabs, itabEntry{t: t, itype: itype, lsym: n.Linksym()})
s, existed := ir.Pkgs.Itab.LookupOK(t.ShortString() + "," + itype.ShortString())
if !existed {
itabs = append(itabs, itabEntry{t: t, itype: itype, lsym: s.Linksym()})
}
n := typecheck.NodAddr(ir.AsNode(s.Def))
n.SetType(types.NewPtr(s.Def.Type()))
n.SetTypecheck(1)
return n
lsym := s.Linksym()
n := ir.NewLinksymExpr(base.Pos, lsym, types.Types[types.TUINT8])
return typecheck.Expr(typecheck.NodAddr(n)).(*ir.AddrExpr)
}
// needkeyupdate reports whether map updates with t as a key

View File

@ -344,7 +344,7 @@ func (s *Schedule) StaticAssign(l *ir.Name, loff int64, r ir.Node, typ *types.Ty
// Create a copy of l to modify while we emit data.
// Emit itab, advance offset.
staticdata.InitAddr(l, loff, itab.X.(*ir.Name).Linksym())
staticdata.InitAddr(l, loff, itab.X.(*ir.LinksymOffsetExpr).Linksym)
// Emit data.
if types.IsDirectIface(val.Type()) {