diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2023-08-09 08:39:47 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-08-11 18:12:07 +0000 |
| commit | e7e5913161e94f77f29443e8b8ddd22714a0f01d (patch) | |
| tree | d31538891e0709be705d6b12c8e67244af3c1374 /src/cmd/compile/internal/noder/unified.go | |
| parent | 59037ac93a49889eb6a7d6b3b8fbc70321615f1f (diff) | |
| download | go-e7e5913161e94f77f29443e8b8ddd22714a0f01d.tar.xz | |
cmd/compile: cleanup ir.Package
Decls used to contain initializer statement for package-level
variables, but now it only contains ir.Funcs. So we might as well
rename it to Funcs and tighten its type to []*ir.Func.
Similarly, Externs always contains *ir.Names, so its type can be
constrained too.
Change-Id: I85b833e2f83d9d3559ab0ef8ab5d8324f4bc37b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/517855
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/noder/unified.go')
| -rw-r--r-- | src/cmd/compile/internal/noder/unified.go | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/src/cmd/compile/internal/noder/unified.go b/src/cmd/compile/internal/noder/unified.go index 0afa505550..3e5ab2ec39 100644 --- a/src/cmd/compile/internal/noder/unified.go +++ b/src/cmd/compile/internal/noder/unified.go @@ -91,27 +91,17 @@ func unified(m posMap, noders []*noder) { r := localPkgReader.newReader(pkgbits.RelocMeta, pkgbits.PrivateRootIdx, pkgbits.SyncPrivate) r.pkgInit(types.LocalPkg, target) - // Type-check any top-level assignments. We ignore non-assignments - // here because other declarations are typechecked as they're - // constructed. - for i, ndecls := 0, len(target.Decls); i < ndecls; i++ { - switch n := target.Decls[i]; n.Op() { - case ir.OAS, ir.OAS2: - target.Decls[i] = typecheck.Stmt(n) - } - } - readBodies(target, false) // Check that nothing snuck past typechecking. - for _, n := range target.Decls { - if n.Typecheck() == 0 { - base.FatalfAt(n.Pos(), "missed typecheck: %v", n) + for _, fn := range target.Funcs { + if fn.Typecheck() == 0 { + base.FatalfAt(fn.Pos(), "missed typecheck: %v", fn) } // For functions, check that at least their first statement (if // any) was typechecked too. - if fn, ok := n.(*ir.Func); ok && len(fn.Body) != 0 { + if len(fn.Body) != 0 { if stmt := fn.Body[0]; stmt.Typecheck() == 0 { base.FatalfAt(stmt.Pos(), "missed typecheck: %v", stmt) } @@ -120,11 +110,9 @@ func unified(m posMap, noders []*noder) { // For functions originally came from package runtime, // mark as norace to prevent instrumenting, see issue #60439. - for _, n := range target.Decls { - if fn, ok := n.(*ir.Func); ok { - if !base.Flag.CompilingRuntime && types.IsRuntimePkg(fn.Sym().Pkg) { - fn.Pragma |= ir.Norace - } + for _, fn := range target.Funcs { + if !base.Flag.CompilingRuntime && types.IsRuntimePkg(fn.Sym().Pkg) { + fn.Pragma |= ir.Norace } } @@ -138,7 +126,7 @@ func unified(m posMap, noders []*noder) { // necessary on instantiations of imported generic functions, so their // inlining costs can be computed. func readBodies(target *ir.Package, duringInlining bool) { - var inlDecls []ir.Node + var inlDecls []*ir.Func // Don't use range--bodyIdx can add closures to todoBodies. for { @@ -175,7 +163,7 @@ func readBodies(target *ir.Package, duringInlining bool) { if duringInlining && canSkipNonGenericMethod { inlDecls = append(inlDecls, fn) } else { - target.Decls = append(target.Decls, fn) + target.Funcs = append(target.Funcs, fn) } } @@ -208,7 +196,7 @@ func readBodies(target *ir.Package, duringInlining bool) { base.Flag.LowerM = oldLowerM for _, fn := range inlDecls { - fn.(*ir.Func).Body = nil // free memory + fn.Body = nil // free memory } } } |
