1
0
mirror of https://github.com/golang/go synced 2024-11-26 14:56:47 -07:00

[dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet in inlining

As CL 282212 mentioned, we should clean all map[*ir.Name]bool with
ir.NameSet.

Passes toolstash -cmp.

Updates #43819

Change-Id: I1ce5d2055f88539f807dc021cd8e3941b425bc4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/284897
Run-TryBot: Baokun Lee <bk@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Baokun Lee <bk@golangcn.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Baokun Lee 2021-01-21 14:13:36 +08:00
parent 68a4664475
commit 970d8b6cb2

View File

@ -73,7 +73,7 @@ func InlinePackage() {
}) })
} }
// Caninl determines whether fn is inlineable. // CanInline determines whether fn is inlineable.
// If so, CanInline saves fn->nbody in fn->inl and substitutes it with a copy. // If so, CanInline saves fn->nbody in fn->inl and substitutes it with a copy.
// fn and ->nbody will already have been typechecked. // fn and ->nbody will already have been typechecked.
func CanInline(fn *ir.Func) { func CanInline(fn *ir.Func) {
@ -169,7 +169,6 @@ func CanInline(fn *ir.Func) {
visitor := hairyVisitor{ visitor := hairyVisitor{
budget: inlineMaxBudget, budget: inlineMaxBudget,
extraCallCost: cc, extraCallCost: cc,
usedLocals: make(map[*ir.Name]bool),
} }
if visitor.tooHairy(fn) { if visitor.tooHairy(fn) {
reason = visitor.reason reason = visitor.reason
@ -254,7 +253,7 @@ type hairyVisitor struct {
budget int32 budget int32
reason string reason string
extraCallCost int32 extraCallCost int32
usedLocals map[*ir.Name]bool usedLocals ir.NameSet
do func(ir.Node) bool do func(ir.Node) bool
} }
@ -410,7 +409,7 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
case ir.ONAME: case ir.ONAME:
n := n.(*ir.Name) n := n.(*ir.Name)
if n.Class == ir.PAUTO { if n.Class == ir.PAUTO {
v.usedLocals[n] = true v.usedLocals.Add(n)
} }
case ir.OBLOCK: case ir.OBLOCK:
@ -1383,7 +1382,7 @@ func pruneUnusedAutos(ll []*ir.Name, vis *hairyVisitor) []*ir.Name {
s := make([]*ir.Name, 0, len(ll)) s := make([]*ir.Name, 0, len(ll))
for _, n := range ll { for _, n := range ll {
if n.Class == ir.PAUTO { if n.Class == ir.PAUTO {
if _, found := vis.usedLocals[n]; !found { if !vis.usedLocals.Has(n) {
continue continue
} }
} }