mirror of
https://github.com/golang/go
synced 2024-11-06 22:36:15 -07:00
[dev.regabi] cmd/compile: cleanup some leftover cruft
Just clearing away some scaffolding artifacts from previous refactorings. [git-generate] cd src/cmd/compile/internal/gc rf ' ex { import "cmd/compile/internal/ir" import "cmd/compile/internal/types" var n *ir.Name; n.Name() -> n var f *ir.Func; f.Func() -> f var o types.Object ir.AsNode(o).Sym() -> o.Sym() ir.AsNode(o).Type() -> o.Type() ir.AsNode(o).(*ir.Name) -> o.(*ir.Name) ir.AsNode(o).(*ir.Func) -> o.(*ir.Func) var x ir.Node ir.AsNode(o) != x -> o != x } ' Change-Id: I946ec344bd7ee274900a392da53b95308ceaade4 Reviewed-on: https://go-review.googlesource.com/c/go/+/274592 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
5ffa275f3c
commit
1408d26ccc
@ -437,7 +437,7 @@ func makepartialcall(dot ir.Node, t0 *types.Type, meth *types.Sym) *ir.Func {
|
||||
sym := methodSymSuffix(rcvrtype, meth, "-fm")
|
||||
|
||||
if sym.Uniq() {
|
||||
return ir.AsNode(sym.Def).(*ir.Func)
|
||||
return sym.Def.(*ir.Func)
|
||||
}
|
||||
sym.SetUniq(true)
|
||||
|
||||
|
@ -95,7 +95,7 @@ func declare(n *ir.Name, ctxt ir.Class) {
|
||||
gen = vargen
|
||||
}
|
||||
types.Pushdcl(s)
|
||||
n.Name().Curfn = Curfn
|
||||
n.Curfn = Curfn
|
||||
}
|
||||
|
||||
if ctxt == ir.PAUTO {
|
||||
@ -113,7 +113,7 @@ func declare(n *ir.Name, ctxt ir.Class) {
|
||||
s.Block = types.Block
|
||||
s.Lastlineno = base.Pos
|
||||
s.Def = n
|
||||
n.Name().Vargen = int32(gen)
|
||||
n.Vargen = int32(gen)
|
||||
n.SetClass(ctxt)
|
||||
if ctxt == ir.PFUNC {
|
||||
n.Sym().SetFunc(true)
|
||||
@ -335,7 +335,7 @@ func colasdefn(left []ir.Node, defn ir.Node) {
|
||||
nnew++
|
||||
n := NewName(n.Sym())
|
||||
declare(n, dclcontext)
|
||||
n.Name().Defn = defn
|
||||
n.Defn = defn
|
||||
defn.PtrInit().Append(ir.Nod(ir.ODCL, n, nil))
|
||||
left[i] = n
|
||||
}
|
||||
@ -438,7 +438,7 @@ func funcarg(n *ir.Field, ctxt ir.Class) {
|
||||
declare(name, ctxt)
|
||||
|
||||
vargen++
|
||||
n.Decl.Name().Vargen = int32(vargen)
|
||||
n.Decl.Vargen = int32(vargen)
|
||||
}
|
||||
|
||||
// Same as funcargs, except run over an already constructed TFUNC.
|
||||
@ -837,7 +837,7 @@ func addmethod(n *ir.Func, msym *types.Sym, t *types.Type, local, nointerface bo
|
||||
}
|
||||
|
||||
f := types.NewField(base.Pos, msym, t)
|
||||
f.Nname = n.Func().Nname
|
||||
f.Nname = n.Nname
|
||||
f.SetNointerface(nointerface)
|
||||
|
||||
mt.Methods().Append(f)
|
||||
|
@ -1802,8 +1802,8 @@ func addrescapes(n ir.Node) {
|
||||
}
|
||||
|
||||
// If a closure reference escapes, mark the outer variable as escaping.
|
||||
if n.Name().IsClosureVar() {
|
||||
addrescapes(n.Name().Defn)
|
||||
if n.IsClosureVar() {
|
||||
addrescapes(n.Defn)
|
||||
break
|
||||
}
|
||||
|
||||
@ -1824,7 +1824,7 @@ func addrescapes(n ir.Node) {
|
||||
// then we're analyzing the inner closure but we need to move x to the
|
||||
// heap in f, not in the inner closure. Flip over to f before calling moveToHeap.
|
||||
oldfn := Curfn
|
||||
Curfn = n.Name().Curfn
|
||||
Curfn = n.Curfn
|
||||
ln := base.Pos
|
||||
base.Pos = Curfn.Pos()
|
||||
moveToHeap(n)
|
||||
@ -1893,7 +1893,7 @@ func moveToHeap(n *ir.Name) {
|
||||
// See issue 16095.
|
||||
heapaddr.SetIsOutputParamHeapAddr(true)
|
||||
}
|
||||
n.Name().Stackcopy = stackcopy
|
||||
n.Stackcopy = stackcopy
|
||||
|
||||
// Substitute the stackcopy into the function variable list so that
|
||||
// liveness and other analyses use the underlying stack slot
|
||||
@ -1920,7 +1920,7 @@ func moveToHeap(n *ir.Name) {
|
||||
// Modify n in place so that uses of n now mean indirection of the heapaddr.
|
||||
n.SetClass(ir.PAUTOHEAP)
|
||||
n.SetOffset(0)
|
||||
n.Name().Heapaddr = heapaddr
|
||||
n.Heapaddr = heapaddr
|
||||
n.SetEsc(EscHeap)
|
||||
if base.Flag.LowerM != 0 {
|
||||
base.WarnfAt(n.Pos(), "moved to heap: %v", n)
|
||||
|
@ -395,7 +395,7 @@ func (p *iexporter) stringOff(s string) uint64 {
|
||||
|
||||
// pushDecl adds n to the declaration work queue, if not already present.
|
||||
func (p *iexporter) pushDecl(n ir.Node) {
|
||||
if n.Sym() == nil || ir.AsNode(n.Sym().Def) != n && n.Op() != ir.OTYPE {
|
||||
if n.Sym() == nil || n.Sym().Def != n && n.Op() != ir.OTYPE {
|
||||
base.Fatalf("weird Sym: %v, %v", n, n.Sym())
|
||||
}
|
||||
|
||||
@ -988,7 +988,7 @@ func (w *exportWriter) funcExt(n *ir.Name) {
|
||||
|
||||
func (w *exportWriter) methExt(m *types.Field) {
|
||||
w.bool(m.Nointerface())
|
||||
w.funcExt(ir.AsNode(m.Nname).(*ir.Name))
|
||||
w.funcExt(m.Nname.(*ir.Name))
|
||||
}
|
||||
|
||||
func (w *exportWriter) linkname(s *types.Sym) {
|
||||
|
@ -60,7 +60,7 @@ func fninit(n []ir.Node) {
|
||||
initializers := lookup("init")
|
||||
fn := dclfunc(initializers, ir.NewFuncType(base.Pos, nil, nil, nil))
|
||||
for _, dcl := range initTodo.Dcl {
|
||||
dcl.Name().Curfn = fn
|
||||
dcl.Curfn = fn
|
||||
}
|
||||
fn.Dcl = append(fn.Dcl, initTodo.Dcl...)
|
||||
initTodo.Dcl = nil
|
||||
|
@ -984,7 +984,7 @@ func clearImports() {
|
||||
}
|
||||
|
||||
func IsAlias(sym *types.Sym) bool {
|
||||
return sym.Def != nil && ir.AsNode(sym.Def).Sym() != sym
|
||||
return sym.Def != nil && sym.Def.Sym() != sym
|
||||
}
|
||||
|
||||
// recordFlags records the specified command-line flags to be placed
|
||||
|
@ -1071,7 +1071,7 @@ func (p *noder) stmtFall(stmt syntax.Stmt, fallOK bool) ir.Node {
|
||||
if ln.Class() != ir.PPARAMOUT {
|
||||
break
|
||||
}
|
||||
if ir.AsNode(ln.Sym().Def) != ln {
|
||||
if ln.Sym().Def != ln {
|
||||
base.Errorf("%s is shadowed during return", ln.Sym().Name)
|
||||
}
|
||||
}
|
||||
|
@ -220,10 +220,10 @@ func addptabs() {
|
||||
}
|
||||
if n.Type().Kind() == types.TFUNC && n.Class() == ir.PFUNC {
|
||||
// function
|
||||
ptabs = append(ptabs, ptabEntry{s: s, t: ir.AsNode(s.Def).Type()})
|
||||
ptabs = append(ptabs, ptabEntry{s: s, t: s.Def.Type()})
|
||||
} else {
|
||||
// variable
|
||||
ptabs = append(ptabs, ptabEntry{s: s, t: types.NewPtr(ir.AsNode(s.Def).Type())})
|
||||
ptabs = append(ptabs, ptabEntry{s: s, t: types.NewPtr(s.Def.Type())})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,8 +77,8 @@ func cmpstackvarlt(a, b *ir.Name) bool {
|
||||
return a.Offset() < b.Offset()
|
||||
}
|
||||
|
||||
if a.Name().Used() != b.Name().Used() {
|
||||
return a.Name().Used()
|
||||
if a.Used() != b.Used() {
|
||||
return a.Used()
|
||||
}
|
||||
|
||||
ap := a.Type().HasPointers()
|
||||
@ -87,8 +87,8 @@ func cmpstackvarlt(a, b *ir.Name) bool {
|
||||
return ap
|
||||
}
|
||||
|
||||
ap = a.Name().Needzero()
|
||||
bp = b.Name().Needzero()
|
||||
ap = a.Needzero()
|
||||
bp = b.Needzero()
|
||||
if ap != bp {
|
||||
return ap
|
||||
}
|
||||
@ -115,7 +115,7 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
|
||||
// Mark the PAUTO's unused.
|
||||
for _, ln := range fn.Dcl {
|
||||
if ln.Class() == ir.PAUTO {
|
||||
ln.Name().SetUsed(false)
|
||||
ln.SetUsed(false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
|
||||
if n.Op() != ir.ONAME || n.Class() != ir.PAUTO {
|
||||
continue
|
||||
}
|
||||
if !n.Name().Used() {
|
||||
if !n.Used() {
|
||||
fn.Dcl = fn.Dcl[:i]
|
||||
break
|
||||
}
|
||||
@ -260,7 +260,7 @@ func compile(fn *ir.Func) {
|
||||
for _, n := range fn.Dcl {
|
||||
switch n.Class() {
|
||||
case ir.PPARAM, ir.PPARAMOUT, ir.PAUTO:
|
||||
if livenessShouldTrack(n) && n.Name().Addrtaken() {
|
||||
if livenessShouldTrack(n) && n.Addrtaken() {
|
||||
dtypesym(n.Type())
|
||||
// Also make sure we allocate a linker symbol
|
||||
// for the stack object data, for the same reason.
|
||||
@ -447,7 +447,7 @@ func debuginfo(fnsym *obj.LSym, infosym *obj.LSym, curfn interface{}) ([]dwarf.S
|
||||
}
|
||||
switch n.Class() {
|
||||
case ir.PAUTO:
|
||||
if !n.Name().Used() {
|
||||
if !n.Used() {
|
||||
// Text == nil -> generating abstract function
|
||||
if fnsym.Func().Text != nil {
|
||||
base.Fatalf("debuginfo unused node (AllocFrame should truncate fn.Func.Dcl)")
|
||||
|
@ -1001,7 +1001,7 @@ func typename(t *types.Type) ir.Node {
|
||||
}
|
||||
|
||||
n := ir.Nod(ir.OADDR, ir.AsNode(s.Def), nil)
|
||||
n.SetType(types.NewPtr(ir.AsNode(s.Def).Type()))
|
||||
n.SetType(types.NewPtr(s.Def.Type()))
|
||||
n.SetTypecheck(1)
|
||||
return n
|
||||
}
|
||||
@ -1021,7 +1021,7 @@ func itabname(t, itype *types.Type) ir.Node {
|
||||
}
|
||||
|
||||
n := ir.Nod(ir.OADDR, ir.AsNode(s.Def), nil)
|
||||
n.SetType(types.NewPtr(ir.AsNode(s.Def).Type()))
|
||||
n.SetType(types.NewPtr(s.Def.Type()))
|
||||
n.SetTypecheck(1)
|
||||
return n
|
||||
}
|
||||
|
@ -6196,7 +6196,7 @@ func (s byXoffset) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
func emitStackObjects(e *ssafn, pp *Progs) {
|
||||
var vars []ir.Node
|
||||
for _, n := range e.curfn.Dcl {
|
||||
if livenessShouldTrack(n) && n.Name().Addrtaken() {
|
||||
if livenessShouldTrack(n) && n.Addrtaken() {
|
||||
vars = append(vars, n)
|
||||
}
|
||||
}
|
||||
@ -6583,7 +6583,7 @@ func defframe(s *SSAGenState, e *ssafn) {
|
||||
|
||||
// Iterate through declarations. They are sorted in decreasing Xoffset order.
|
||||
for _, n := range e.curfn.Dcl {
|
||||
if !n.Name().Needzero() {
|
||||
if !n.Needzero() {
|
||||
continue
|
||||
}
|
||||
if n.Class() != ir.PAUTO {
|
||||
|
@ -2493,7 +2493,7 @@ func lookdot(n ir.Node, t *types.Type, dostrcmp int) *types.Field {
|
||||
pll = ll
|
||||
ll = ll.Left()
|
||||
}
|
||||
if pll.Implicit() && ll.Type().IsPtr() && ll.Type().Sym() != nil && ir.AsNode(ll.Type().Sym().Def) != nil && ir.AsNode(ll.Type().Sym().Def).Op() == ir.OTYPE {
|
||||
if pll.Implicit() && ll.Type().IsPtr() && ll.Type().Sym() != nil && ll.Type().Sym().Def != nil && ir.AsNode(ll.Type().Sym().Def).Op() == ir.OTYPE {
|
||||
// It is invalid to automatically dereference a named pointer type when selecting a method.
|
||||
// Make n.Left == ll to clarify error message.
|
||||
n.SetLeft(ll)
|
||||
@ -3369,7 +3369,7 @@ func typecheckfunc(n *ir.Func) {
|
||||
|
||||
for _, ln := range n.Dcl {
|
||||
if ln.Op() == ir.ONAME && (ln.Class() == ir.PPARAM || ln.Class() == ir.PPARAMOUT) {
|
||||
ln.Name().Decldepth = 1
|
||||
ln.Decldepth = 1
|
||||
}
|
||||
}
|
||||
|
||||
@ -3923,7 +3923,7 @@ func curpkg() *types.Pkg {
|
||||
// referenced by expression n, which must be a method selector,
|
||||
// method expression, or method value.
|
||||
func methodExprName(n ir.Node) *ir.Name {
|
||||
name, _ := ir.AsNode(methodExprFunc(n).Nname).(*ir.Name)
|
||||
name, _ := methodExprFunc(n).Nname.(*ir.Name)
|
||||
return name
|
||||
}
|
||||
|
||||
|
@ -358,5 +358,5 @@ func finishUniverse() {
|
||||
nodfp = NewName(lookup(".fp"))
|
||||
nodfp.SetType(types.Types[types.TINT32])
|
||||
nodfp.SetClass(ir.PPARAM)
|
||||
nodfp.Name().SetUsed(true)
|
||||
nodfp.SetUsed(true)
|
||||
}
|
||||
|
@ -43,16 +43,16 @@ func walk(fn *ir.Func) {
|
||||
|
||||
// Propagate the used flag for typeswitch variables up to the NONAME in its definition.
|
||||
for _, ln := range fn.Dcl {
|
||||
if ln.Op() == ir.ONAME && (ln.Class() == ir.PAUTO || ln.Class() == ir.PAUTOHEAP) && ln.Name().Defn != nil && ln.Name().Defn.Op() == ir.OTYPESW && ln.Name().Used() {
|
||||
ln.Name().Defn.Left().Name().SetUsed(true)
|
||||
if ln.Op() == ir.ONAME && (ln.Class() == ir.PAUTO || ln.Class() == ir.PAUTOHEAP) && ln.Defn != nil && ln.Defn.Op() == ir.OTYPESW && ln.Used() {
|
||||
ln.Defn.Left().Name().SetUsed(true)
|
||||
}
|
||||
}
|
||||
|
||||
for _, ln := range fn.Dcl {
|
||||
if ln.Op() != ir.ONAME || (ln.Class() != ir.PAUTO && ln.Class() != ir.PAUTOHEAP) || ln.Sym().Name[0] == '&' || ln.Name().Used() {
|
||||
if ln.Op() != ir.ONAME || (ln.Class() != ir.PAUTO && ln.Class() != ir.PAUTOHEAP) || ln.Sym().Name[0] == '&' || ln.Used() {
|
||||
continue
|
||||
}
|
||||
if defn := ln.Name().Defn; defn != nil && defn.Op() == ir.OTYPESW {
|
||||
if defn := ln.Defn; defn != nil && defn.Op() == ir.OTYPESW {
|
||||
if defn.Left().Name().Used() {
|
||||
continue
|
||||
}
|
||||
@ -91,7 +91,7 @@ func paramoutheap(fn *ir.Func) bool {
|
||||
for _, ln := range fn.Dcl {
|
||||
switch ln.Class() {
|
||||
case ir.PPARAMOUT:
|
||||
if isParamStackCopy(ln) || ln.Name().Addrtaken() {
|
||||
if isParamStackCopy(ln) || ln.Addrtaken() {
|
||||
return true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user