mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[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:
parent
c4bd0b7474
commit
e84b27bec5
34 changed files with 627 additions and 633 deletions
|
|
@ -277,7 +277,7 @@ func Main(archInit func(*Arch)) {
|
|||
for i := 0; i < len(xtop); i++ {
|
||||
n := xtop[i]
|
||||
if n.Op() == ir.ODCLFUNC {
|
||||
Curfn = n
|
||||
Curfn = n.(*ir.Func)
|
||||
decldepth = 1
|
||||
errorsBefore := base.Errors()
|
||||
typecheckslice(Curfn.Body().Slice(), ctxStmt)
|
||||
|
|
@ -307,8 +307,8 @@ func Main(archInit func(*Arch)) {
|
|||
timings.Start("fe", "capturevars")
|
||||
for _, n := range xtop {
|
||||
if n.Op() == ir.ODCLFUNC && n.Func().OClosure != nil {
|
||||
Curfn = n
|
||||
capturevars(n)
|
||||
Curfn = n.(*ir.Func)
|
||||
capturevars(Curfn)
|
||||
}
|
||||
}
|
||||
capturevarscomplete = true
|
||||
|
|
@ -321,7 +321,7 @@ func Main(archInit func(*Arch)) {
|
|||
// Typecheck imported function bodies if Debug.l > 1,
|
||||
// otherwise lazily when used or re-exported.
|
||||
for _, n := range importlist {
|
||||
if n.Func().Inl != nil {
|
||||
if n.Inl != nil {
|
||||
typecheckinl(n)
|
||||
}
|
||||
}
|
||||
|
|
@ -330,7 +330,7 @@ func Main(archInit func(*Arch)) {
|
|||
|
||||
if base.Flag.LowerL != 0 {
|
||||
// Find functions that can be inlined and clone them before walk expands them.
|
||||
visitBottomUp(xtop, func(list []ir.Node, recursive bool) {
|
||||
visitBottomUp(xtop, func(list []*ir.Func, recursive bool) {
|
||||
numfns := numNonClosures(list)
|
||||
for _, n := range list {
|
||||
if !recursive || numfns > 1 {
|
||||
|
|
@ -340,7 +340,7 @@ func Main(archInit func(*Arch)) {
|
|||
caninl(n)
|
||||
} else {
|
||||
if base.Flag.LowerM > 1 {
|
||||
fmt.Printf("%v: cannot inline %v: recursive\n", ir.Line(n), n.Func().Nname)
|
||||
fmt.Printf("%v: cannot inline %v: recursive\n", ir.Line(n), n.Nname)
|
||||
}
|
||||
}
|
||||
inlcalls(n)
|
||||
|
|
@ -350,7 +350,7 @@ func Main(archInit func(*Arch)) {
|
|||
|
||||
for _, n := range xtop {
|
||||
if n.Op() == ir.ODCLFUNC {
|
||||
devirtualize(n)
|
||||
devirtualize(n.(*ir.Func))
|
||||
}
|
||||
}
|
||||
Curfn = nil
|
||||
|
|
@ -380,8 +380,8 @@ func Main(archInit func(*Arch)) {
|
|||
timings.Start("fe", "xclosures")
|
||||
for _, n := range xtop {
|
||||
if n.Op() == ir.ODCLFUNC && n.Func().OClosure != nil {
|
||||
Curfn = n
|
||||
transformclosure(n)
|
||||
Curfn = n.(*ir.Func)
|
||||
transformclosure(Curfn)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -403,7 +403,7 @@ func Main(archInit func(*Arch)) {
|
|||
for i := 0; i < len(xtop); i++ {
|
||||
n := xtop[i]
|
||||
if n.Op() == ir.ODCLFUNC {
|
||||
funccompile(n)
|
||||
funccompile(n.(*ir.Func))
|
||||
fcount++
|
||||
}
|
||||
}
|
||||
|
|
@ -481,10 +481,10 @@ func Main(archInit func(*Arch)) {
|
|||
}
|
||||
|
||||
// numNonClosures returns the number of functions in list which are not closures.
|
||||
func numNonClosures(list []ir.Node) int {
|
||||
func numNonClosures(list []*ir.Func) int {
|
||||
count := 0
|
||||
for _, n := range list {
|
||||
if n.Func().OClosure == nil {
|
||||
for _, fn := range list {
|
||||
if fn.OClosure == nil {
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue