aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/gc/main.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-11-28 07:31:18 -0500
committerRuss Cox <rsc@golang.org>2020-11-30 18:34:01 +0000
commite84b27bec587e4393533e83e3ea1cbf1ed548425 (patch)
tree6b858504b1a1e485e9405a956b874808cd6fba8c /src/cmd/compile/internal/gc/main.go
parentc4bd0b7474f169a60acf66306a4a721f790e36c9 (diff)
downloadgo-e84b27bec587e4393533e83e3ea1cbf1ed548425.tar.gz
go-e84b27bec587e4393533e83e3ea1cbf1ed548425.zip
[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>
Diffstat (limited to 'src/cmd/compile/internal/gc/main.go')
-rw-r--r--src/cmd/compile/internal/gc/main.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go
index 931626159d..7bad05265d 100644
--- a/src/cmd/compile/internal/gc/main.go
+++ b/src/cmd/compile/internal/gc/main.go
@@ -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++
}
}