[dev.regabi] cmd/compile: clean up Name and Func uses

Now that we have specific types for ONAME and ODCLFUNC nodes
(*Name and *Func), use them throughout the compiler to be more
precise about what data is being operated on.

This is a somewhat large CL, but once you start applying the types
in a few places, you end up needing to apply them to many other
places to keep everything type-checking. A lot of code also melts
away as types are added.

Passes buildall w/ toolstash -cmp.

Change-Id: I21dd9b945d701c470332bac5394fca744a5b232d
Reviewed-on: https://go-review.googlesource.com/c/go/+/274097
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Russ Cox 2020-11-28 07:31:18 -05:00
parent c4bd0b7474
commit e84b27bec5
34 changed files with 627 additions and 633 deletions

View file

@ -19,7 +19,7 @@ var renameinitgen int
// Function collecting autotmps generated during typechecking,
// to be included in the package-level init function.
var initTodo = ir.Nod(ir.ODCLFUNC, nil, nil)
var initTodo = ir.NewFunc(base.Pos)
func renameinit() *types.Sym {
s := lookupN("init.", renameinitgen)
@ -49,23 +49,23 @@ func fninit(n []ir.Node) {
base.Pos = nf[0].Pos() // prolog/epilog gets line number of first init stmt
initializers := lookup("init")
fn := dclfunc(initializers, ir.Nod(ir.OTFUNC, nil, nil))
for _, dcl := range initTodo.Func().Dcl {
for _, dcl := range initTodo.Dcl {
dcl.Name().Curfn = fn
}
fn.Func().Dcl = append(fn.Func().Dcl, initTodo.Func().Dcl...)
initTodo.Func().Dcl = nil
fn.Dcl = append(fn.Dcl, initTodo.Dcl...)
initTodo.Dcl = nil
fn.PtrBody().Set(nf)
funcbody()
fn = typecheck(fn, ctxStmt)
typecheckFunc(fn)
Curfn = fn
typecheckslice(nf, ctxStmt)
Curfn = nil
xtop = append(xtop, fn)
fns = append(fns, initializers.Linksym())
}
if initTodo.Func().Dcl != nil {
if initTodo.Dcl != nil {
// We only generate temps using initTodo if there
// are package-scope initialization statements, so
// something's weird if we get here.