]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: remove extra typ field in Name struct
authorDan Scales <danscales@google.com>
Wed, 2 Dec 2020 04:51:18 +0000 (20:51 -0800)
committerDan Scales <danscales@google.com>
Thu, 3 Dec 2020 07:22:32 +0000 (07:22 +0000)
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 <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/compile/internal/ir/func.go
src/cmd/compile/internal/ir/name.go
src/cmd/compile/internal/ir/sizeof_test.go

index 3fc8597ef05188bf392d2cd69a35b94d0ece42cf..98830fb502d648df62e73781a444e9ff7c6f2916 100644 (file)
@@ -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
index 3c62800ad31ef8118d7defcd8c049540137a8192..1d886bb9a1af6011af01c856ae901cbf6ea8eeb2 100644 (file)
@@ -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
index 4a133cb9991533abaf05b838f744a4fd74f26124..181f1462fe97c9fdc11f8f17c17c08a358b7e8b9 100644 (file)
@@ -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 {