1
0
mirror of https://github.com/golang/go synced 2024-11-11 19:51:37 -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) {
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