Skip to content

Commit 970d8b6

Browse files
committed
[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 <[email protected]> TryBot-Result: Go Bot <[email protected]> Trust: Baokun Lee <[email protected]> Reviewed-by: Cuong Manh Le <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 68a4664 commit 970d8b6

File tree

1 file changed

+4
-5
lines changed
  • src/cmd/compile/internal/inline

1 file changed

+4
-5
lines changed

src/cmd/compile/internal/inline/inl.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func InlinePackage() {
7373
})
7474
}
7575

76-
// Caninl determines whether fn is inlineable.
76+
// CanInline determines whether fn is inlineable.
7777
// If so, CanInline saves fn->nbody in fn->inl and substitutes it with a copy.
7878
// fn and ->nbody will already have been typechecked.
7979
func CanInline(fn *ir.Func) {
@@ -169,7 +169,6 @@ func CanInline(fn *ir.Func) {
169169
visitor := hairyVisitor{
170170
budget: inlineMaxBudget,
171171
extraCallCost: cc,
172-
usedLocals: make(map[*ir.Name]bool),
173172
}
174173
if visitor.tooHairy(fn) {
175174
reason = visitor.reason
@@ -254,7 +253,7 @@ type hairyVisitor struct {
254253
budget int32
255254
reason string
256255
extraCallCost int32
257-
usedLocals map[*ir.Name]bool
256+
usedLocals ir.NameSet
258257
do func(ir.Node) bool
259258
}
260259

@@ -410,7 +409,7 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
410409
case ir.ONAME:
411410
n := n.(*ir.Name)
412411
if n.Class == ir.PAUTO {
413-
v.usedLocals[n] = true
412+
v.usedLocals.Add(n)
414413
}
415414

416415
case ir.OBLOCK:
@@ -1383,7 +1382,7 @@ func pruneUnusedAutos(ll []*ir.Name, vis *hairyVisitor) []*ir.Name {
13831382
s := make([]*ir.Name, 0, len(ll))
13841383
for _, n := range ll {
13851384
if n.Class == ir.PAUTO {
1386-
if _, found := vis.usedLocals[n]; !found {
1385+
if !vis.usedLocals.Has(n) {
13871386
continue
13881387
}
13891388
}

0 commit comments

Comments
 (0)