cmd/compile: switch to final unified IR export format

Now that there's a native go/types importer for unified IR, the
compiler no longer needs to stay backwards compatible with old iexport
importers.

This CL also updates the go/types and go/internal/gcimporter tests to
expect that the unified IR importer sets the receiver parameter type
to the underlying Interface type, rather than the Named type. This is
a temporary workaround until we make a decision on #49906.

Notably, this makes `GOEXPERIMENT=unified go test` work on generics
code without requiring `-vet=off` (because previously cmd/vet was
relying on unified IR's backwards-compatible iexport data, which
omitted generic types).

Change-Id: Iac7a2346bb7a91e6690fb2978fb702fadae5559d
Reviewed-on: https://go-review.googlesource.com/c/go/+/386004
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Matthew Dempsky 2022-02-15 11:39:41 -08:00
parent deaec2ecb3
commit e146d3eafa
7 changed files with 90 additions and 134 deletions

View file

@ -16,7 +16,6 @@ import (
"sort"
"cmd/compile/internal/base"
"cmd/compile/internal/importer"
"cmd/compile/internal/inline"
"cmd/compile/internal/ir"
"cmd/compile/internal/typecheck"
@ -74,17 +73,6 @@ var localPkgReader *pkgReader
func unified(noders []*noder) {
inline.NewInline = InlineCall
writeNewExportFunc = writeNewExport
newReadImportFunc = func(data string, pkg1 *types.Pkg, ctxt *types2.Context, packages map[string]*types2.Package) (pkg2 *types2.Package, err error) {
pr := pkgbits.NewPkgDecoder(pkg1.Path, data)
// Read package descriptors for both types2 and compiler backend.
readPackage(newPkgReader(pr), pkg1)
pkg2 = importer.ReadPackage(ctxt, packages, pr)
return
}
data := writePkgStub(noders)
// We already passed base.Flag.Lang to types2 to handle validating
@ -266,7 +254,7 @@ func readPackage(pr *pkgReader, importpkg *types.Pkg) {
}
}
func writeNewExport(out io.Writer) {
func writeUnifiedExport(out io.Writer) {
l := linker{
pw: pkgbits.NewPkgEncoder(base.Debug.SyncFrames),
@ -332,5 +320,5 @@ func writeNewExport(out io.Writer) {
w.Flush()
}
l.pw.DumpTo(out)
base.Ctxt.Fingerprint = l.pw.DumpTo(out)
}