]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet for SSA
authorBaokun Lee <bk@golangcn.org>
Thu, 21 Jan 2021 07:07:25 +0000 (15:07 +0800)
committerBaokun Lee <bk@golangcn.org>
Thu, 21 Jan 2021 09:56:12 +0000 (09:56 +0000)
Same as CL 284897, but for SSA.

Passes toolstash -cmp.

Updates #43819

Change-Id: I3c500ad635a3192d95d16fdc36f154ba3ea5df69
Reviewed-on: https://go-review.googlesource.com/c/go/+/284898
Run-TryBot: Baokun Lee <bk@golangcn.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Baokun Lee <bk@golangcn.org>

src/cmd/compile/internal/ssa/deadstore.go

index 530918da4d61d94f64b04186807d48f94ee047bb..0cf9931dbcd83d077890c9c0c937555abf3bc4f3 100644 (file)
@@ -139,7 +139,7 @@ func dse(f *Func) {
 func elimDeadAutosGeneric(f *Func) {
        addr := make(map[*Value]*ir.Name) // values that the address of the auto reaches
        elim := make(map[*Value]*ir.Name) // values that could be eliminated if the auto is
-       used := make(map[*ir.Name]bool)   // used autos that must be kept
+       var used ir.NameSet               // used autos that must be kept
 
        // visit the value and report whether any of the maps are updated
        visit := func(v *Value) (changed bool) {
@@ -178,8 +178,8 @@ func elimDeadAutosGeneric(f *Func) {
                        if !ok || n.Class != ir.PAUTO {
                                return
                        }
-                       if !used[n] {
-                               used[n] = true
+                       if !used.Has(n) {
+                               used.Add(n)
                                changed = true
                        }
                        return
@@ -212,8 +212,8 @@ func elimDeadAutosGeneric(f *Func) {
                if v.Type.IsMemory() || v.Type.IsFlags() || v.Op == OpPhi || v.MemoryArg() != nil {
                        for _, a := range args {
                                if n, ok := addr[a]; ok {
-                                       if !used[n] {
-                                               used[n] = true
+                                       if !used.Has(n) {
+                                               used.Add(n)
                                                changed = true
                                        }
                                }
@@ -224,7 +224,7 @@ func elimDeadAutosGeneric(f *Func) {
                // Propagate any auto addresses through v.
                var node *ir.Name
                for _, a := range args {
-                       if n, ok := addr[a]; ok && !used[n] {
+                       if n, ok := addr[a]; ok && !used.Has(n) {
                                if node == nil {
                                        node = n
                                } else if node != n {
@@ -233,7 +233,7 @@ func elimDeadAutosGeneric(f *Func) {
                                        // multiple pointers (e.g. NeqPtr, Phi etc.).
                                        // This is rare, so just propagate the first
                                        // value to keep things simple.
-                                       used[n] = true
+                                       used.Add(n)
                                        changed = true
                                }
                        }
@@ -249,7 +249,7 @@ func elimDeadAutosGeneric(f *Func) {
                }
                if addr[v] != node {
                        // This doesn't happen in practice, but catch it just in case.
-                       used[node] = true
+                       used.Add(node)
                        changed = true
                }
                return
@@ -269,8 +269,8 @@ func elimDeadAutosGeneric(f *Func) {
                        }
                        // keep the auto if its address reaches a control value
                        for _, c := range b.ControlValues() {
-                               if n, ok := addr[c]; ok && !used[n] {
-                                       used[n] = true
+                               if n, ok := addr[c]; ok && !used.Has(n) {
+                                       used.Add(n)
                                        changed = true
                                }
                        }
@@ -282,7 +282,7 @@ func elimDeadAutosGeneric(f *Func) {
 
        // Eliminate stores to unread autos.
        for v, n := range elim {
-               if used[n] {
+               if used.Has(n) {
                        continue
                }
                // replace with OpCopy