diff options
author | Baokun Lee <bk@golangcn.org> | 2021-01-21 14:13:36 +0800 |
---|---|---|
committer | Baokun Lee <bk@golangcn.org> | 2021-01-21 09:55:49 +0000 |
commit | 970d8b6cb2ca5302f09a4eb8bfe90c4baea9cf88 (patch) | |
tree | dc9260442f6c62c7a51307038c9d62ffc5ba9c38 /src/cmd/compile/internal/inline | |
parent | 68a46644752b6bc8de8d2b82b7f2354f3b52b50a (diff) | |
download | go-970d8b6cb2ca5302f09a4eb8bfe90c4baea9cf88.tar.gz go-970d8b6cb2ca5302f09a4eb8bfe90c4baea9cf88.zip |
[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>
Diffstat (limited to 'src/cmd/compile/internal/inline')
-rw-r--r-- | src/cmd/compile/internal/inline/inl.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index 46f093b1f8..83f6740a48 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -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. // fn and ->nbody will already have been typechecked. func CanInline(fn *ir.Func) { @@ -169,7 +169,6 @@ func CanInline(fn *ir.Func) { visitor := hairyVisitor{ budget: inlineMaxBudget, extraCallCost: cc, - usedLocals: make(map[*ir.Name]bool), } if visitor.tooHairy(fn) { reason = visitor.reason @@ -254,7 +253,7 @@ type hairyVisitor struct { budget int32 reason string extraCallCost int32 - usedLocals map[*ir.Name]bool + usedLocals ir.NameSet do func(ir.Node) bool } @@ -410,7 +409,7 @@ func (v *hairyVisitor) doNode(n ir.Node) bool { case ir.ONAME: n := n.(*ir.Name) if n.Class == ir.PAUTO { - v.usedLocals[n] = true + v.usedLocals.Add(n) } case ir.OBLOCK: @@ -1383,7 +1382,7 @@ func pruneUnusedAutos(ll []*ir.Name, vis *hairyVisitor) []*ir.Name { s := make([]*ir.Name, 0, len(ll)) for _, n := range ll { if n.Class == ir.PAUTO { - if _, found := vis.usedLocals[n]; !found { + if !vis.usedLocals.Has(n) { continue } } |