[dev.regabi] cmd/compile: rewrite to use linksym helpers [generated]

Passes toolstash -cmp.

[git-generate]
cd src/cmd/compile/internal/gc
pkgs=$(grep -l -w Linksym ../*/*.go | xargs dirname | grep -v '/gc$' | sort -u)
rf '
	ex . '"$(echo $pkgs)"' {
		import "cmd/compile/internal/ir"
		import "cmd/compile/internal/reflectdata"
		import "cmd/compile/internal/staticdata"
		import "cmd/compile/internal/types"

		avoid reflectdata.TypeLinksym
		avoid reflectdata.TypeLinksymLookup
		avoid reflectdata.TypeLinksymPrefix
		avoid staticdata.FuncLinksym

		var f *ir.Func
		var n *ir.Name
		var s string
		var t *types.Type

		f.Sym().Linksym() -> f.Linksym()
		n.Sym().Linksym() -> n.Linksym()

		reflectdata.TypeSym(t).Linksym() -> reflectdata.TypeLinksym(t)
		reflectdata.TypeSymPrefix(s, t).Linksym() -> reflectdata.TypeLinksymPrefix(s, t)
		staticdata.FuncSym(n.Sym()).Linksym() -> staticdata.FuncLinksym(n)
		types.TypeSymLookup(s).Linksym() -> reflectdata.TypeLinksymLookup(s)
	}
'

Change-Id: I7a3ae1dcd61bcdf4a29f708ff12f7f80c2b280c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/280640
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
Matthew Dempsky 2020-12-28 19:34:35 -08:00
parent 25c613c02d
commit ec59b197d5
17 changed files with 44 additions and 44 deletions

View File

@ -26,7 +26,7 @@ func Info(fnsym *obj.LSym, infosym *obj.LSym, curfn interface{}) ([]dwarf.Scope,
fn := curfn.(*ir.Func)
if fn.Nname != nil {
expect := fn.Sym().Linksym()
expect := fn.Linksym()
if fnsym.ABI() == obj.ABI0 {
expect = fn.Sym().LinksymABI0()
}
@ -90,7 +90,7 @@ func Info(fnsym *obj.LSym, infosym *obj.LSym, curfn interface{}) ([]dwarf.Scope,
continue
}
apdecls = append(apdecls, n)
fnsym.Func().RecordAutoType(reflectdata.TypeSym(n.Type()).Linksym())
fnsym.Func().RecordAutoType(reflectdata.TypeLinksym(n.Type()))
}
}
@ -240,7 +240,7 @@ func createDwarfVars(fnsym *obj.LSym, complexOK bool, fn *ir.Func, apDecls []*ir
ChildIndex: -1,
})
// Record go type of to insure that it gets emitted by the linker.
fnsym.Func().RecordAutoType(reflectdata.TypeSym(n.Type()).Linksym())
fnsym.Func().RecordAutoType(reflectdata.TypeLinksym(n.Type()))
}
return decls, vars
@ -309,7 +309,7 @@ func createSimpleVar(fnsym *obj.LSym, n *ir.Name) *dwarf.Var {
}
typename := dwarf.InfoPrefix + types.TypeSymName(n.Type())
delete(fnsym.Func().Autot, reflectdata.TypeSym(n.Type()).Linksym())
delete(fnsym.Func().Autot, reflectdata.TypeLinksym(n.Type()))
inlIndex := 0
if base.Flag.GenDwarfInl > 1 {
if n.Name().InlFormal() || n.Name().InlLocal() {
@ -376,7 +376,7 @@ func createComplexVar(fnsym *obj.LSym, fn *ir.Func, varID ssa.VarID) *dwarf.Var
return nil
}
gotype := reflectdata.TypeSym(n.Type()).Linksym()
gotype := reflectdata.TypeLinksym(n.Type())
delete(fnsym.Func().Autot, gotype)
typename := dwarf.InfoPrefix + gotype.Name[len("type."):]
inlIndex := 0

View File

@ -40,10 +40,10 @@ func TestMain(m *testing.M) {
types.PtrSize = ssagen.Arch.LinkArch.PtrSize
types.RegSize = ssagen.Arch.LinkArch.RegSize
types.TypeLinkSym = func(t *types.Type) *obj.LSym {
return reflectdata.TypeSym(t).Linksym()
return reflectdata.TypeLinksym(t)
}
types.TypeLinkSym = func(t *types.Type) *obj.LSym {
return reflectdata.TypeSym(t).Linksym()
return reflectdata.TypeLinksym(t)
}
typecheck.Init()
os.Exit(m.Run())

View File

@ -174,5 +174,5 @@ func isInlinableButNotInlined(fn *ir.Func) bool {
if fn.Sym() == nil {
return true
}
return !fn.Sym().Linksym().WasInlined()
return !fn.Linksym().WasInlined()
}

View File

@ -191,7 +191,7 @@ func Main(archInit func(*ssagen.ArchInfo)) {
types.RegSize = ssagen.Arch.LinkArch.RegSize
types.MaxWidth = ssagen.Arch.MAXWIDTH
types.TypeLinkSym = func(t *types.Type) *obj.LSym {
return reflectdata.TypeSym(t).Linksym()
return reflectdata.TypeLinksym(t)
}
typecheck.Target = new(ir.Package)
@ -203,7 +203,7 @@ func Main(archInit func(*ssagen.ArchInfo)) {
base.AutogeneratedPos = makePos(src.NewFileBase("<autogenerated>", "<autogenerated>"), 1, 0)
types.TypeLinkSym = func(t *types.Type) *obj.LSym {
return reflectdata.TypeSym(t).Linksym()
return reflectdata.TypeLinksym(t)
}
typecheck.Init()

View File

@ -261,8 +261,8 @@ func addGCLocals() {
}
func ggloblnod(nam *ir.Name) {
s := nam.Sym().Linksym()
s.Gotype = reflectdata.TypeSym(nam.Type()).Linksym()
s := nam.Linksym()
s.Gotype = reflectdata.TypeLinksym(nam.Type())
flags := 0
if nam.Name().Readonly() {
flags = obj.RODATA

View File

@ -932,7 +932,7 @@ func mkinlcall(n *ir.CallExpr, fn *ir.Func, maxCost int32, inlMap map[*ir.Func]b
parent = b.InliningIndex()
}
sym := fn.Sym().Linksym()
sym := fn.Linksym()
newIndex := base.Ctxt.InlTree.Add(parent, n.Pos(), sym)
// Add an inline mark just before the inlined body.

View File

@ -314,7 +314,7 @@ func (n *Name) MarkReadonly() {
// Mark the linksym as readonly immediately
// so that the SSA backend can use this information.
// It will be overridden later during dumpglobls.
n.Sym().Linksym().Type = objabi.SRODATA
n.Linksym().Type = objabi.SRODATA
}
// Val returns the constant.Value for the node.

View File

@ -34,7 +34,7 @@ func Task() *ir.Name {
if n.Op() != ir.ONAME || n.(*ir.Name).Class_ != ir.PEXTERN {
base.Fatalf("bad inittask: %v", n)
}
deps = append(deps, n.(*ir.Name).Sym().Linksym())
deps = append(deps, n.(*ir.Name).Linksym())
}
// Make a function that contains all the initialization statements.
@ -74,7 +74,7 @@ func Task() *ir.Name {
continue
}
}
fns = append(fns, fn.Nname.Sym().Linksym())
fns = append(fns, fn.Nname.Linksym())
}
if len(deps) == 0 && len(fns) == 0 && types.LocalPkg.Name != "main" && types.LocalPkg.Name != "runtime" {

View File

@ -104,7 +104,7 @@ func genhash(t *types.Type) *obj.LSym {
// For other sizes of plain memory, we build a closure
// that calls memhash_varlen. The size of the memory is
// encoded in the first slot of the closure.
closure := types.TypeSymLookup(fmt.Sprintf(".hashfunc%d", t.Width)).Linksym()
closure := TypeLinksymLookup(fmt.Sprintf(".hashfunc%d", t.Width))
if len(closure.P) > 0 { // already generated
return closure
}
@ -120,7 +120,7 @@ func genhash(t *types.Type) *obj.LSym {
break
}
closure := TypeSymPrefix(".hashfunc", t).Linksym()
closure := TypeLinksymPrefix(".hashfunc", t)
if len(closure.P) > 0 { // already generated
return closure
}
@ -347,7 +347,7 @@ func geneq(t *types.Type) *obj.LSym {
case types.AMEM:
// make equality closure. The size of the type
// is encoded in the closure.
closure := types.TypeSymLookup(fmt.Sprintf(".eqfunc%d", t.Width)).Linksym()
closure := TypeLinksymLookup(fmt.Sprintf(".eqfunc%d", t.Width))
if len(closure.P) != 0 {
return closure
}
@ -363,7 +363,7 @@ func geneq(t *types.Type) *obj.LSym {
break
}
closure := TypeSymPrefix(".eqfunc", t).Linksym()
closure := TypeLinksymPrefix(".eqfunc", t)
if len(closure.P) > 0 { // already generated
return closure
}

View File

@ -1583,7 +1583,7 @@ func dgcprog(t *types.Type) (*obj.LSym, int64) {
if t.Width == types.BADWIDTH {
base.Fatalf("dgcprog: %v badwidth", t)
}
lsym := TypeSymPrefix(".gcprog", t).Linksym()
lsym := TypeLinksymPrefix(".gcprog", t)
var p gcProg
p.init(lsym)
p.emit(t, 0)
@ -1857,7 +1857,7 @@ var ZeroSize int64
// MarkTypeUsedInInterface marks that type t is converted to an interface.
// This information is used in the linker in dead method elimination.
func MarkTypeUsedInInterface(t *types.Type, from *obj.LSym) {
tsym := TypeSym(t).Linksym()
tsym := TypeLinksym(t)
// Emit a marker relocation. The linker will know the type is converted
// to an interface if "from" is reachable.
r := obj.Addrel(from)
@ -1870,7 +1870,7 @@ func MarkTypeUsedInInterface(t *types.Type, from *obj.LSym) {
func MarkUsedIfaceMethod(n *ir.CallExpr) {
dot := n.X.(*ir.SelectorExpr)
ityp := dot.X.Type()
tsym := TypeSym(ityp).Linksym()
tsym := TypeLinksym(ityp)
r := obj.Addrel(ir.CurFunc.LSym)
r.Sym = tsym
// dot.Xoffset is the method index * Widthptr (the offset of code pointer

View File

@ -166,7 +166,7 @@ func selectLSym(f *ir.Func, hasBody bool) {
f.LSym = nam.Sym().LinksymABI0()
needABIWrapper, wrapperABI = true, obj.ABIInternal
} else {
f.LSym = nam.Sym().Linksym()
f.LSym = nam.Linksym()
// No ABI override. Check that the symbol is
// using the expected ABI.
want := obj.ABIInternal

View File

@ -2112,7 +2112,7 @@ func (s *state) expr(n ir.Node) *ssa.Value {
n := n.(*ir.Name)
if n.Class_ == ir.PFUNC {
// "value" of a function is the address of the function's closure
sym := staticdata.FuncSym(n.Sym()).Linksym()
sym := staticdata.FuncLinksym(n)
return s.entryNewValue1A(ssa.OpAddr, types.NewPtr(n.Type()), sym, s.sb)
}
if s.canSSA(n) {
@ -4959,7 +4959,7 @@ func (s *state) addr(n ir.Node) *ssa.Value {
switch n.Class_ {
case ir.PEXTERN:
// global variable
v := s.entryNewValue1A(ssa.OpAddr, t, n.Sym().Linksym(), s.sb)
v := s.entryNewValue1A(ssa.OpAddr, t, n.Linksym(), s.sb)
// TODO: Make OpAddr use AuxInt as well as Aux.
if offset != 0 {
v = s.entryNewValue1I(ssa.OpOffPtr, v.Type, offset, v)
@ -6831,7 +6831,7 @@ func AddAux2(a *obj.Addr, v *ssa.Value, offset int64) {
break
}
a.Name = obj.NAME_AUTO
a.Sym = n.Sym().Linksym()
a.Sym = n.Linksym()
a.Offset += n.FrameOffset()
default:
v.Fatalf("aux in %s not implemented %#v", v, v.Aux)
@ -6963,7 +6963,7 @@ func CheckLoweredGetClosurePtr(v *ssa.Value) {
func AddrAuto(a *obj.Addr, v *ssa.Value) {
n, off := ssa.AutoVar(v)
a.Type = obj.TYPE_MEM
a.Sym = n.Sym().Linksym()
a.Sym = n.Linksym()
a.Reg = int16(Arch.REGSP)
a.Offset = n.FrameOffset() + off
if n.Class_ == ir.PPARAM || n.Class_ == ir.PPARAMOUT {
@ -6979,7 +6979,7 @@ func (s *State) AddrScratch(a *obj.Addr) {
}
a.Type = obj.TYPE_MEM
a.Name = obj.NAME_AUTO
a.Sym = s.ScratchFpMem.Sym().Linksym()
a.Sym = s.ScratchFpMem.Linksym()
a.Reg = int16(Arch.REGSP)
a.Offset = s.ScratchFpMem.Offset_
}

View File

@ -37,8 +37,8 @@ func InitAddr(n *ir.Name, noff int64, a *ir.Name, aoff int64) {
if a.Op() != ir.ONAME {
base.Fatalf("addrsym a op %v", a.Op())
}
s := n.Sym().Linksym()
s.WriteAddr(base.Ctxt, noff, types.PtrSize, a.Sym().Linksym(), aoff)
s := n.Linksym()
s.WriteAddr(base.Ctxt, noff, types.PtrSize, a.Linksym(), aoff)
}
// InitFunc writes the static address of f to n. f must be a global function.
@ -53,18 +53,18 @@ func InitFunc(n *ir.Name, noff int64, f *ir.Name) {
if f.Class_ != ir.PFUNC {
base.Fatalf("pfuncsym class not PFUNC %d", f.Class_)
}
s := n.Sym().Linksym()
s.WriteAddr(base.Ctxt, noff, types.PtrSize, FuncSym(f.Sym()).Linksym(), 0)
s := n.Linksym()
s.WriteAddr(base.Ctxt, noff, types.PtrSize, FuncLinksym(f), 0)
}
// InitSlice writes a static slice symbol {&arr, lencap, lencap} to n+noff.
// InitSlice does not modify n.
func InitSlice(n *ir.Name, noff int64, arr *ir.Name, lencap int64) {
s := n.Sym().Linksym()
s := n.Linksym()
if arr.Op() != ir.ONAME {
base.Fatalf("slicesym non-name arr %v", arr)
}
s.WriteAddr(base.Ctxt, noff, types.PtrSize, arr.Sym().Linksym(), 0)
s.WriteAddr(base.Ctxt, noff, types.PtrSize, arr.Linksym(), 0)
s.WriteInt(base.Ctxt, noff+types.SliceLenOffset, types.PtrSize, lencap)
s.WriteInt(base.Ctxt, noff+types.SliceCapOffset, types.PtrSize, lencap)
}
@ -141,7 +141,7 @@ func fileStringSym(pos src.XPos, file string, readonly bool, hash []byte) (*obj.
if readonly {
sym = StringSym(pos, string(data))
} else {
sym = slicedata(pos, string(data)).Sym().Linksym()
sym = slicedata(pos, string(data)).Linksym()
}
if len(hash) > 0 {
sum := sha256.Sum256(data)
@ -189,7 +189,7 @@ func fileStringSym(pos src.XPos, file string, readonly bool, hash []byte) (*obj.
} else {
// Emit a zero-length data symbol
// and then fix up length and content to use file.
symdata = slicedata(pos, "").Sym().Linksym()
symdata = slicedata(pos, "").Linksym()
symdata.Size = size
symdata.Type = objabi.SNOPTRDATA
info := symdata.NewFileInfo()
@ -318,7 +318,7 @@ func InitConst(n *ir.Name, noff int64, c ir.Node, wid int) {
if c.Op() != ir.OLITERAL {
base.Fatalf("litsym c op %v", c.Op())
}
s := n.Sym().Linksym()
s := n.Linksym()
switch u := c.Val(); u.Kind() {
case constant.Bool:
i := int64(obj.Bool2int(constant.BoolVal(u)))

View File

@ -145,7 +145,7 @@ func WriteEmbed(v *ir.Name) {
if err != nil {
base.ErrorfAt(v.Pos(), "embed %s: %v", file, err)
}
sym := v.Sym().Linksym()
sym := v.Linksym()
off := 0
off = objw.SymPtr(sym, off, fsym, 0) // data string
off = objw.Uintptr(sym, off, uint64(size)) // len
@ -187,7 +187,7 @@ func WriteEmbed(v *ir.Name) {
}
}
objw.Global(slicedata, int32(off), obj.RODATA|obj.LOCAL)
sym := v.Sym().Linksym()
sym := v.Linksym()
objw.SymPtr(sym, 0, slicedata, 0)
}
}

View File

@ -313,7 +313,7 @@ func (s *Schedule) StaticAssign(l *ir.Name, loff int64, r ir.Node, typ *types.Ty
return val.Op() == ir.ONIL
}
reflectdata.MarkTypeUsedInInterface(val.Type(), l.Sym().Linksym())
reflectdata.MarkTypeUsedInInterface(val.Type(), l.Linksym())
var itab *ir.AddrExpr
if typ.IsEmptyInterface() {
@ -445,7 +445,7 @@ func StaticName(t *types.Type) *ir.Name {
statuniqgen++
typecheck.Declare(n, ir.PEXTERN)
n.SetType(t)
n.Sym().Linksym().Set(obj.AttrLocal, true)
n.Linksym().Set(obj.AttrLocal, true)
return n
}

View File

@ -59,7 +59,7 @@ func (c initContext) String() string {
func readonlystaticname(t *types.Type) *ir.Name {
n := staticinit.StaticName(t)
n.MarkReadonly()
n.Sym().Linksym().Set(obj.AttrContentAddressable, true)
n.Linksym().Set(obj.AttrContentAddressable, true)
return n
}

View File

@ -14,7 +14,7 @@ import (
)
func instrument(fn *ir.Func) {
if fn.Pragma&ir.Norace != 0 || (fn.Sym().Linksym() != nil && fn.Sym().Linksym().ABIWrapper()) {
if fn.Pragma&ir.Norace != 0 || (fn.Linksym() != nil && fn.Linksym().ABIWrapper()) {
return
}