aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/dcl.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-01-11 15:07:09 -0800
committerMatthew Dempsky <mdempsky@google.com>2021-01-12 03:15:18 +0000
commit12ee55ba7bf22157267e735e8e4bbf651c5b4e7d (patch)
treea024598854c7bc9f41d4e7497c2c07cb52a9c4cf /src/cmd/compile/internal/typecheck/dcl.go
parentb4d2a0445b0ca54a159e0895e1a8b31d47411894 (diff)
downloadgo-12ee55ba7bf22157267e735e8e4bbf651c5b4e7d.tar.gz
go-12ee55ba7bf22157267e735e8e4bbf651c5b4e7d.zip
[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 <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> Trust: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/dcl.go')
-rw-r--r--src/cmd/compile/internal/typecheck/dcl.go27
1 files changed, 1 insertions, 26 deletions
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)
}