]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fuse escape analysis parameter tagging loops
authorMatthew Dempsky <mdempsky@google.com>
Wed, 7 Mar 2018 23:11:54 +0000 (15:11 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 8 Mar 2018 18:21:52 +0000 (18:21 +0000)
Simplifies the code somewhat and allows removing Param.Field.

Passes toolstash-check.

Change-Id: Id854416aea8afd27ce4830ff0f5ff940f7353792
Reviewed-on: https://go-review.googlesource.com/99336
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/esc.go
src/cmd/compile/internal/gc/sizeof_test.go
src/cmd/compile/internal/gc/syntax.go

index ce1033cf258c08dcdf4877d680bde8449ffa956e..1fa68e9f4a5b6132f7472b19a17ba42dc0ea5cf7 100644 (file)
@@ -668,11 +668,6 @@ func tofunargs(l []*Node, funarg types.Funarg) *types.Type {
        for i, n := range l {
                f := structfield(n)
                f.Funarg = funarg
-
-               // esc.go needs to find f given a PPARAM to add the tag.
-               if n.Left != nil && n.Left.Class() == PPARAM {
-                       n.Left.Name.Param.Field = f
-               }
                if f.Broke() {
                        t.SetBroke(true)
                }
@@ -688,11 +683,6 @@ func tofunargsfield(fields []*types.Field, funarg types.Funarg) *types.Type {
 
        for _, f := range fields {
                f.Funarg = funarg
-
-               // esc.go needs to find f given a PPARAM to add the tag.
-               if asNode(f.Nname) != nil && asNode(f.Nname).Class() == PPARAM {
-                       asNode(f.Nname).Name.Param.Field = f
-               }
        }
        t.SetFields(fields)
        return t
index eed863aa13d8300117003c0b09b642594ee3fad5..48945e2868f4003a33a81e03b741ab66ba050953 100644 (file)
@@ -2238,27 +2238,6 @@ func (e *EscState) esctag(fn *Node) {
                }
        }
 
-       for _, ln := range fn.Func.Dcl {
-               if ln.Op != ONAME {
-                       continue
-               }
-
-               switch ln.Esc & EscMask {
-               case EscNone, // not touched by escflood
-                       EscReturn:
-                       if types.Haspointers(ln.Type) { // don't bother tagging for scalars
-                               if ln.Name.Param.Field.Note != uintptrEscapesTag {
-                                       ln.Name.Param.Field.Note = mktag(int(ln.Esc))
-                               }
-                       }
-
-               case EscHeap: // touched by escflood, moved to heap
-               }
-       }
-
-       // Unnamed parameters are unused and therefore do not escape.
-       // (Unnamed parameters are not in the Dcl list in the loop above
-       // so we need to mark them separately.)
        for _, fs := range types.RecvsParams {
                for _, f := range fs(fn.Type).Fields().Slice() {
                        if !types.Haspointers(f.Type) { // don't bother tagging for scalars
@@ -2268,8 +2247,19 @@ func (e *EscState) esctag(fn *Node) {
                                // Note is already set in the loop above.
                                continue
                        }
+
+                       // Unnamed parameters are unused and therefore do not escape.
                        if f.Sym == nil || f.Sym.IsBlank() {
                                f.Note = mktag(EscNone)
+                               continue
+                       }
+
+                       switch esc := asNode(f.Nname).Esc; esc & EscMask {
+                       case EscNone, // not touched by escflood
+                               EscReturn:
+                               f.Note = mktag(int(esc))
+
+                       case EscHeap: // touched by escflood, moved to heap
                        }
                }
        }
index d649fd58d30e789ca39526b0665bdf4d95fc7b4a..358814c5ce3a14eac14e3a6e881af83c693f31d8 100644 (file)
@@ -24,7 +24,7 @@ func TestSizeof(t *testing.T) {
        }{
                {Func{}, 128, 232},
                {Name{}, 32, 56},
-               {Param{}, 28, 56},
+               {Param{}, 24, 48},
                {Node{}, 76, 128},
        }
 
index 65ecbeede200b541be875b0ae0016a06d353b816..edc9e4ea03bb03c836a83b15be96d143e89d8f18 100644 (file)
@@ -279,9 +279,6 @@ type Param struct {
        // ONAME PAUTOHEAP
        Stackcopy *Node // the PPARAM/PPARAMOUT on-stack slot (moved func params only)
 
-       // ONAME PPARAM
-       Field *types.Field // TFIELD in arg struct
-
        // ONAME closure linkage
        // Consider:
        //