Skip to content

Commit

Permalink
[dev.regabi] cmd/compile: use LinksymOffsetExpr in TypePtr/ItabAddr
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cuonglm committed Jan 18, 2021
1 parent 0ffa1ea commit 4c835f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
37 changes: 10 additions & 27 deletions src/cmd/compile/internal/reflectdata/reflect.go
Expand Up @@ -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()})
}

n := typecheck.NodAddr(ir.AsNode(s.Def))
n.SetType(types.NewPtr(s.Def.Type()))
n.SetTypecheck(1)
return n
s, existed := ir.Pkgs.Itab.LookupOK(t.ShortString() + "," + itype.ShortString())
if !existed {
itabs = append(itabs, itabEntry{t: t, itype: itype, lsym: s.Linksym()})
}

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
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/staticinit/sched.go
Expand Up @@ -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()) {
Expand Down

0 comments on commit 4c835f9

Please sign in to comment.