1
0
mirror of https://github.com/golang/go synced 2024-11-23 16:00:06 -07:00

[dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet for SSA

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>
This commit is contained in:
Baokun Lee 2021-01-21 15:07:25 +08:00
parent 970d8b6cb2
commit 5248f59a22

View File

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