1
0
mirror of https://github.com/golang/go synced 2024-11-17 20:14:45 -07:00

[dev.regabi] cmd/compile: remove Name.Typegen

Just directly set Type.Vargen when declaring defined types within a
function.

Change-Id: Idcc0007084a660ce1c39da4a3697e158a1c615b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/283212
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
Matthew Dempsky 2021-01-11 17:22:20 -08:00
parent 12ee55ba7b
commit 95acd8121b
4 changed files with 11 additions and 14 deletions

View File

@ -55,10 +55,6 @@ type Name struct {
// The function, method, or closure in which local variable or param is declared.
Curfn *Func
// Unique number for OTYPE names within a function.
// TODO(mdempsky): Remove completely.
Typegen int32
Ntype Ntype
Heapaddr *Name // temp holding heap address of param

View File

@ -21,7 +21,7 @@ func TestSizeof(t *testing.T) {
_64bit uintptr // size on 64bit platforms
}{
{Func{}, 184, 320},
{Name{}, 120, 216},
{Name{}, 116, 208},
}
for _, tt := range tests {

View File

@ -62,10 +62,6 @@ func Declare(n *ir.Name, ctxt ir.Class) {
if ir.CurFunc != nil && ctxt != ir.PFUNC && n.Op() == ir.ONAME {
ir.CurFunc.Dcl = append(ir.CurFunc.Dcl, n)
}
if n.Op() == ir.OTYPE {
declare_typegen++
n.Typegen = int32(declare_typegen)
}
types.Pushdcl(s)
n.Curfn = ir.CurFunc
}
@ -308,10 +304,6 @@ func checkembeddedtype(t *types.Type) {
}
}
// declare individual names - var, typ, const
var declare_typegen int
func fakeRecvField() *types.Field {
return types.NewField(src.NoXPos, nil, types.FakeRecvType())
}

View File

@ -1681,13 +1681,22 @@ func CheckMapKeys() {
mapqueue = nil
}
// typegen tracks the number of function-scoped defined types that
// have been declared. It's used to generate unique linker symbols for
// their runtime type descriptors.
var typegen int32
func typecheckdeftype(n *ir.Name) {
if base.EnableTrace && base.Flag.LowerT {
defer tracePrint("typecheckdeftype", n)(nil)
}
t := types.NewNamed(n)
t.Vargen = n.Typegen
if n.Curfn != nil {
typegen++
t.Vargen = typegen
}
if n.Pragma()&ir.NotInHeap != 0 {
t.SetNotInHeap(true)
}