From 12ee55ba7bf22157267e735e8e4bbf651c5b4e7d Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Mon, 11 Jan 2021 15:07:09 -0800 Subject: [dev.regabi] cmd/compile: stop using Vargen for import/export Historically, inline function bodies were exported as plain Go source code, and symbol mangling was a convenient hack because it allowed variables to be re-imported with largely the same names as they were originally exported as. However, nowadays we use a binary format that's more easily extended, so we can simply serialize all of a function's declared objects up front, and then refer to them by index later on. This also allows us to easily report unmangled names all the time (e.g., error message from issue7921.go). Fixes #43633. Change-Id: I46c88f5a47cb921f70ab140976ba9ddce38df216 Reviewed-on: https://go-review.googlesource.com/c/go/+/283193 Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Dan Scales Trust: Dan Scales Trust: Matthew Dempsky --- src/cmd/compile/internal/typecheck/dcl.go | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) (limited to 'src/cmd/compile/internal/typecheck/dcl.go') diff --git a/src/cmd/compile/internal/typecheck/dcl.go b/src/cmd/compile/internal/typecheck/dcl.go index ffbf474a58..caa3e8203a 100644 --- a/src/cmd/compile/internal/typecheck/dcl.go +++ b/src/cmd/compile/internal/typecheck/dcl.go @@ -7,7 +7,6 @@ package typecheck import ( "fmt" "strconv" - "strings" "cmd/compile/internal/base" "cmd/compile/internal/ir" @@ -47,7 +46,6 @@ func Declare(n *ir.Name, ctxt ir.Class) { base.ErrorfAt(n.Pos(), "cannot declare name %v", s) } - gen := 0 if ctxt == ir.PEXTERN { if s.Name == "init" { base.ErrorfAt(n.Pos(), "cannot declare init - must be func") @@ -66,10 +64,7 @@ func Declare(n *ir.Name, ctxt ir.Class) { } if n.Op() == ir.OTYPE { declare_typegen++ - gen = declare_typegen - } else if n.Op() == ir.ONAME && ctxt == ir.PAUTO && !strings.Contains(s.Name, "ยท") { - vargen++ - gen = vargen + n.Typegen = int32(declare_typegen) } types.Pushdcl(s) n.Curfn = ir.CurFunc @@ -90,7 +85,6 @@ func Declare(n *ir.Name, ctxt ir.Class) { s.Block = types.Block s.Lastlineno = base.Pos s.Def = n - n.Vargen = int32(gen) n.Class = ctxt if ctxt == ir.PFUNC { n.Sym().SetFunc(true) @@ -338,9 +332,6 @@ func funcarg(n *ir.Field, ctxt ir.Class) { n.Decl = name name.Ntype = n.Ntype Declare(name, ctxt) - - vargen++ - n.Decl.Vargen = int32(vargen) } func funcarg2(f *types.Field, ctxt ir.Class) { @@ -358,15 +349,6 @@ func funcargs(nt *ir.FuncType) { base.Fatalf("funcargs %v", nt.Op()) } - // re-start the variable generation number - // we want to use small numbers for the return variables, - // so let them have the chunk starting at 1. - // - // TODO(mdempsky): This is ugly, and only necessary because - // esc.go uses Vargen to figure out result parameters' index - // within the result tuple. - vargen = len(nt.Results) - // declare the receiver and in arguments. if nt.Recv != nil { funcarg(nt.Recv, ir.PPARAM) @@ -375,9 +357,6 @@ func funcargs(nt *ir.FuncType) { funcarg(n, ir.PPARAM) } - oldvargen := vargen - vargen = 0 - // declare the out arguments. gen := len(nt.Params) for _, n := range nt.Results { @@ -399,8 +378,6 @@ func funcargs(nt *ir.FuncType) { funcarg(n, ir.PPARAMOUT) } - - vargen = oldvargen } // Same as funcargs, except run over an already constructed TFUNC. @@ -422,8 +399,6 @@ func funcargs2(t *types.Type) { } } -var vargen int - func Temp(t *types.Type) *ir.Name { return TempAt(base.Pos, ir.CurFunc, t) } -- cgit v1.2.3-54-g00ecf