mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: support new fully-inst types referenced during inlining
Modify the phase for creating needed function/method instantiations and modifying functions to use those instantiations, so that the phase is self-contained and can be called again after inlining. This is to deal with the issue that inlining may reveal new fully-instantiated types whose methods must be instantiated. With this change, we have an extra phase for instantiation after inlining, to take care of the new fully-instantiated types that have shown up during inlining. We call inline.InlineCalls() for any new instantiated functions that are created. Change-Id: I4ddf0b1907e5f1f7d45891db7876455a99381133 Reviewed-on: https://go-review.googlesource.com/c/go/+/352870 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Alexander Rakoczy <alex@golang.org>
This commit is contained in:
parent
fad4a16fd4
commit
a80e53ec43
7 changed files with 355 additions and 224 deletions
|
|
@ -158,16 +158,6 @@ type irgen struct {
|
|||
// types which we need to finish, by doing g.fillinMethods.
|
||||
typesToFinalize []*typeDelayInfo
|
||||
|
||||
dnum int // for generating unique dictionary variables
|
||||
|
||||
// Map from a name of function that been instantiated to information about
|
||||
// its instantiated function (including dictionary format).
|
||||
instInfoMap map[*types.Sym]*instInfo
|
||||
|
||||
// dictionary syms which we need to finish, by writing out any itabconv
|
||||
// entries.
|
||||
dictSymsToFinalize []*delayInfo
|
||||
|
||||
// True when we are compiling a top-level generic function or method. Use to
|
||||
// avoid adding closures of generic functions/methods to the target.Decls
|
||||
// list.
|
||||
|
|
@ -180,6 +170,23 @@ type irgen struct {
|
|||
curDecl string
|
||||
}
|
||||
|
||||
// genInst has the information for creating needed instantiations and modifying
|
||||
// functions to use instantiations.
|
||||
type genInst struct {
|
||||
dnum int // for generating unique dictionary variables
|
||||
|
||||
// Map from the names of all instantiations to information about the
|
||||
// instantiations.
|
||||
instInfoMap map[*types.Sym]*instInfo
|
||||
|
||||
// Dictionary syms which we need to finish, by writing out any itabconv
|
||||
// entries.
|
||||
dictSymsToFinalize []*delayInfo
|
||||
|
||||
// New instantiations created during this round of buildInstantiations().
|
||||
newInsts []ir.Node
|
||||
}
|
||||
|
||||
func (g *irgen) later(fn func()) {
|
||||
g.laterFuncs = append(g.laterFuncs, fn)
|
||||
}
|
||||
|
|
@ -308,8 +315,9 @@ Outer:
|
|||
|
||||
typecheck.DeclareUniverse()
|
||||
|
||||
// Create any needed stencils of generic functions
|
||||
g.stencil()
|
||||
// Create any needed instantiations of generic functions and transform
|
||||
// existing and new functions to use those instantiations.
|
||||
BuildInstantiations(true)
|
||||
|
||||
// Remove all generic functions from g.target.Decl, since they have been
|
||||
// used for stenciling, but don't compile. Generic functions will already
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue