cmd/compile/internal/ir: drop Inl.Body

We don't actually depend on Inl.Body anywhere, except it implicitly
serves to indicate whether Inl.Dcl has been populated. So replace it
with a boolean so we don't need to keep a useless copy of every
inlinable function body in memory.

While here, also add some Fatalfs to make sure there are no unused
local variables. The unified frontend now omits unreachable code
during export data writing, so there shouldn't be unused local
variables.

Also, since unified IR uses the same code/data to construct the
original function as inlined and/or imported functions, the Dcl list
should always be the same, which addresses the real root issue (i.e.,
that export/import could skew the Dcl lists).

Change-Id: I6e3435f3a0352f6efbae787344006efac1891e84
Reviewed-on: https://go-review.googlesource.com/c/go/+/523315
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Matthew Dempsky 2023-08-26 16:37:24 -07:00 committed by Gopher Robot
parent ad74bc4a92
commit 08bf6d1405
4 changed files with 22 additions and 55 deletions

View file

@ -193,12 +193,12 @@ func (f *Func) LinksymABI(abi obj.ABI) *obj.LSym { return f.Nname.LinksymABI(abi
type Inline struct {
Cost int32 // heuristic cost of inlining this function
// Copies of Func.Dcl and Func.Body for use during inlining. Copies are
// needed because the function's dcl/body may be changed by later compiler
// transformations. These fields are also populated when a function from
// another package is imported.
Dcl []*Name
Body []Node
// Copy of Func.Dcl for use during inlining. This copy is needed
// because the function's Dcl may change from later compiler
// transformations. This field is also populated when a function
// from another package is imported and inlined.
Dcl []*Name
HaveDcl bool // whether we've loaded Dcl
// CanDelayResults reports whether it's safe for the inliner to delay
// initializing the result parameters until immediately before the