Skip to content

Commit 4c835f9

Browse files
committed
[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 <[email protected]> TryBot-Result: Go Bot <[email protected]> Trust: Cuong Manh Le <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 0ffa1ea commit 4c835f9

File tree

2 files changed

+11
-28
lines changed

2 files changed

+11
-28
lines changed

src/cmd/compile/internal/reflectdata/reflect.go

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -836,39 +836,22 @@ func TypeLinksym(t *types.Type) *obj.LSym {
836836
}
837837

838838
func TypePtr(t *types.Type) *ir.AddrExpr {
839-
s := TypeSym(t)
840-
if s.Def == nil {
841-
n := ir.NewNameAt(src.NoXPos, s)
842-
n.SetType(types.Types[types.TUINT8])
843-
n.Class = ir.PEXTERN
844-
n.SetTypecheck(1)
845-
s.Def = n
846-
}
847-
848-
n := typecheck.NodAddr(ir.AsNode(s.Def))
849-
n.SetType(types.NewPtr(s.Def.Type()))
850-
n.SetTypecheck(1)
851-
return n
839+
n := ir.NewLinksymExpr(base.Pos, TypeLinksym(t), types.Types[types.TUINT8])
840+
return typecheck.Expr(typecheck.NodAddr(n)).(*ir.AddrExpr)
852841
}
853842

854843
func ITabAddr(t, itype *types.Type) *ir.AddrExpr {
855844
if t == nil || (t.IsPtr() && t.Elem() == nil) || t.IsUntyped() || !itype.IsInterface() || itype.IsEmptyInterface() {
856845
base.Fatalf("ITabAddr(%v, %v)", t, itype)
857846
}
858-
s := ir.Pkgs.Itab.Lookup(t.ShortString() + "," + itype.ShortString())
859-
if s.Def == nil {
860-
n := typecheck.NewName(s)
861-
n.SetType(types.Types[types.TUINT8])
862-
n.Class = ir.PEXTERN
863-
n.SetTypecheck(1)
864-
s.Def = n
865-
itabs = append(itabs, itabEntry{t: t, itype: itype, lsym: n.Linksym()})
866-
}
867-
868-
n := typecheck.NodAddr(ir.AsNode(s.Def))
869-
n.SetType(types.NewPtr(s.Def.Type()))
870-
n.SetTypecheck(1)
871-
return n
847+
s, existed := ir.Pkgs.Itab.LookupOK(t.ShortString() + "," + itype.ShortString())
848+
if !existed {
849+
itabs = append(itabs, itabEntry{t: t, itype: itype, lsym: s.Linksym()})
850+
}
851+
852+
lsym := s.Linksym()
853+
n := ir.NewLinksymExpr(base.Pos, lsym, types.Types[types.TUINT8])
854+
return typecheck.Expr(typecheck.NodAddr(n)).(*ir.AddrExpr)
872855
}
873856

874857
// needkeyupdate reports whether map updates with t as a key

src/cmd/compile/internal/staticinit/sched.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ func (s *Schedule) StaticAssign(l *ir.Name, loff int64, r ir.Node, typ *types.Ty
344344
// Create a copy of l to modify while we emit data.
345345

346346
// Emit itab, advance offset.
347-
staticdata.InitAddr(l, loff, itab.X.(*ir.Name).Linksym())
347+
staticdata.InitAddr(l, loff, itab.X.(*ir.LinksymOffsetExpr).Linksym)
348348

349349
// Emit data.
350350
if types.IsDirectIface(val.Type()) {

0 commit comments

Comments
 (0)