From: Dan Scales Date: Wed, 2 Dec 2020 04:51:18 +0000 (-0800) Subject: [dev.regabi] cmd/compile: remove extra typ field in Name struct X-Git-Tag: go1.17beta1~1539^2~389 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5a3b6796cd;p=gostls13.git [dev.regabi] cmd/compile: remove extra typ field in Name struct Noticed the typ field was duplicated, since it is also in miniExpr inside Name. Also clarified the comments for Func, now that it is actually the ODCLFUNC node. Change-Id: Ia483a0ad34bb409cd92c43d4ae0a6852f9e4f644 Reviewed-on: https://go-review.googlesource.com/c/go/+/274619 Run-TryBot: Dan Scales TryBot-Result: Go Bot Trust: Dan Scales Reviewed-by: Russ Cox --- diff --git a/src/cmd/compile/internal/ir/func.go b/src/cmd/compile/internal/ir/func.go index 3fc8597ef0..98830fb502 100644 --- a/src/cmd/compile/internal/ir/func.go +++ b/src/cmd/compile/internal/ir/func.go @@ -17,13 +17,14 @@ import ( // // There are multiple nodes that represent a Func in the IR. // -// The ONAME node (Func.Name) is used for plain references to it. -// The ODCLFUNC node (Func.Decl) is used for its declaration code. -// The OCLOSURE node (Func.Closure) is used for a reference to a +// The ONAME node (Func.Nname) is used for plain references to it. +// The ODCLFUNC node (the Func itself) is used for its declaration code. +// The OCLOSURE node (Func.OClosure) is used for a reference to a // function literal. // -// A Func for an imported function will have only an ONAME node. -// A declared function or method has an ONAME and an ODCLFUNC. +// An imported function will have an ONAME node which points to a Func +// with an empty body. +// A declared function or method has an ODCLFUNC (the Func itself) and an ONAME. // A function literal is represented directly by an OCLOSURE, but it also // has an ODCLFUNC (and a matching ONAME) representing the compiled // underlying form of the closure, which accesses the captured variables @@ -44,8 +45,8 @@ import ( // the method name is stored in Sym instead of Right. // Each OCALLPART ends up being implemented as a new // function, a bit like a closure, with its own ODCLFUNC. -// The OCALLPART has uses n.Func to record the linkage to -// the generated ODCLFUNC (as n.Func.Decl), but there is no +// The OCALLPART uses n.Func to record the linkage to +// the generated ODCLFUNC, but there is no // pointer from the Func back to the OCALLPART. type Func struct { miniNode diff --git a/src/cmd/compile/internal/ir/name.go b/src/cmd/compile/internal/ir/name.go index 3c62800ad3..1d886bb9a1 100644 --- a/src/cmd/compile/internal/ir/name.go +++ b/src/cmd/compile/internal/ir/name.go @@ -21,7 +21,6 @@ type Name struct { flags bitset16 pragma PragmaFlag // int16 sym *types.Sym - typ *types.Type fn *Func offset int64 val constant.Value diff --git a/src/cmd/compile/internal/ir/sizeof_test.go b/src/cmd/compile/internal/ir/sizeof_test.go index 4a133cb999..181f1462fe 100644 --- a/src/cmd/compile/internal/ir/sizeof_test.go +++ b/src/cmd/compile/internal/ir/sizeof_test.go @@ -21,7 +21,7 @@ func TestSizeof(t *testing.T) { _64bit uintptr // size on 64bit platforms }{ {Func{}, 168, 288}, - {Name{}, 128, 224}, + {Name{}, 124, 216}, } for _, tt := range tests {