]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile: fix windows longtest builder
authorMatthew Dempsky <mdempsky@google.com>
Wed, 7 Jul 2021 11:03:24 +0000 (04:03 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 7 Jul 2021 18:12:43 +0000 (18:12 +0000)
CL 332469 broke the Windows longtest builders, because it changed the
names assigned to autotmp variables that end up in export data.

The naming of autotmps doesn't actually matter, so instead we can just
hack iexport to write out "$autotmp" as a magic marker, and let the
reader replace it with an appropriate unique name. This is a little
hacky, but so is iexport's handling of autotmps already, and this
should also go away eventually with unified IR.

Change-Id: Ic17395337c745b66b9d63ee566299290214e6273
Reviewed-on: https://go-review.googlesource.com/c/go/+/333089
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/compile/internal/typecheck/iexport.go
src/cmd/compile/internal/typecheck/iimport.go

index b717c373f5fb030babf1fccda87e047056b17591..0a48078bd0f0a52346b410481f91eb106aaf1c44 100644 (file)
@@ -2116,8 +2116,15 @@ func (w *exportWriter) localIdent(s *types.Sym) {
                return
        }
 
-       // TODO(mdempsky): Fix autotmp hack.
-       if i := strings.LastIndex(name, "."); i >= 0 && !strings.HasPrefix(name, ".autotmp_") && !strings.HasPrefix(name, ".dict") { // TODO: just use autotmp names for dictionaries?
+       // The name of autotmp variables isn't important; they just need to
+       // be unique. To stabilize the export data, simply write out "$" as
+       // a marker and let the importer generate its own unique name.
+       if strings.HasPrefix(name, ".autotmp_") {
+               w.string("$autotmp")
+               return
+       }
+
+       if i := strings.LastIndex(name, "."); i >= 0 && !strings.HasPrefix(name, ".dict") { // TODO: just use autotmp names for dictionaries?
                base.Fatalf("unexpected dot in identifier: %v", name)
        }
 
index f178869e285a0f19d226d86ed774404d542e83ef..7b7cd7f148d38a625f3f3d2caf903dfd99538f1c 100644 (file)
@@ -265,6 +265,7 @@ type importReader struct {
        // Slice of all dcls for function, including any interior closures
        allDcls        []*ir.Name
        allClosureVars []*ir.Name
+       autotmpgen     int
 }
 
 func (p *iimporter) newReader(off uint64, pkg *types.Pkg) *importReader {
@@ -516,8 +517,15 @@ func (r *importReader) ident(selector bool) *types.Sym {
                return nil
        }
        pkg := r.currPkg
-       if selector && types.IsExported(name) {
-               pkg = types.LocalPkg
+       if selector {
+               if types.IsExported(name) {
+                       pkg = types.LocalPkg
+               }
+       } else {
+               if name == "$autotmp" {
+                       name = autotmpname(r.autotmpgen)
+                       r.autotmpgen++
+               }
        }
        return pkg.Lookup(name)
 }