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/reader.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/reader.go')
| -rw-r--r-- | src/cmd/compile/internal/noder/reader.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go index a92a890437..0f936b4764 100644 --- a/src/cmd/compile/internal/noder/reader.go +++ b/src/cmd/compile/internal/noder/reader.go @@ -3015,7 +3015,14 @@ func (r *reader) tempCopy(pos src.XPos, expr ir.Node, init *ir.Nodes) *ir.Name { assign.Def = true tmp.Defn = assign - typecheck.Target.Decls = append(typecheck.Target.Decls, typecheck.Stmt(assign)) + // TODO(mdempsky): This code doesn't work anymore, because we now + // rely on types2 to compute InitOrder. If it's going to be used + // for testing again, the assignment here probably needs to be + // added to typecheck.Target.InitOrder somewhere. + // + // Probably just easier to address the escape analysis limitation. + // + // typecheck.Target.Decls = append(typecheck.Target.Decls, typecheck.Stmt(assign)) return tmp } @@ -3353,14 +3360,14 @@ func (r *reader) pkgDecls(target *ir.Package) { case declFunc: names := r.pkgObjs(target) assert(len(names) == 1) - target.Decls = append(target.Decls, names[0].Func) + target.Funcs = append(target.Funcs, names[0].Func) case declMethod: typ := r.typ() _, sym := r.selector() method := typecheck.Lookdot1(nil, sym, typ, typ.Methods(), 0) - target.Decls = append(target.Decls, method.Nname.(*ir.Name).Func) + target.Funcs = append(target.Funcs, method.Nname.(*ir.Name).Func) case declVar: names := r.pkgObjs(target) @@ -3629,7 +3636,7 @@ func expandInline(fn *ir.Func, pri pkgReaderIndex) { // with the same information some other way. fndcls := len(fn.Dcl) - topdcls := len(typecheck.Target.Decls) + topdcls := len(typecheck.Target.Funcs) tmpfn := ir.NewFunc(fn.Pos()) tmpfn.Nname = ir.NewNameAt(fn.Nname.Pos(), fn.Sym()) @@ -3661,7 +3668,7 @@ func expandInline(fn *ir.Func, pri pkgReaderIndex) { // typecheck.Stmts may have added function literals to // typecheck.Target.Decls. Remove them again so we don't risk trying // to compile them multiple times. - typecheck.Target.Decls = typecheck.Target.Decls[:topdcls] + typecheck.Target.Funcs = typecheck.Target.Funcs[:topdcls] } // usedLocals returns a set of local variables that are used within body. @@ -3925,7 +3932,7 @@ func finishWrapperFunc(fn *ir.Func, target *ir.Package) { } }) - target.Decls = append(target.Decls, fn) + target.Funcs = append(target.Funcs, fn) } // newWrapperType returns a copy of the given signature type, but with |
