Now that we're bootstrapping from a toolchain that has the clear builtin.
Update #64751
Change-Id: Ia86d96c253c9f7c66131cd02048a493047569641
Reviewed-on: https://go-review.googlesource.com/c/go/+/610237
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
allCallSites[call] = cs
}
}
- for k := range scoreCallsCache.tab {
- delete(scoreCallsCache.tab, k)
- }
+ clear(scoreCallsCache.tab)
}
// GetCallSiteScore returns the previously calculated score for call
rawcands[n] = struct{}{}
}
for k := 0; k < len(cs.f.Blocks); k++ {
- genmapclear(pendingUses)
- genmapclear(blockIndirectUE)
+ clear(pendingUses)
+ clear(blockIndirectUE)
b := cs.f.Blocks[k]
for _, v := range b.Values {
if n, e := affectedVar(v); n != nil {
// that value is flowing out of the block off somewhere else,
// we're going to treat that local as truly address-taken and
// not have it be a merge candidate.
- genmapclear(evicted)
+ clear(evicted)
if len(pendingUses) != 0 {
for id, nc := range pendingUses {
if cs.trace > 2 {
return pruned, regions
}
-// FIXME: bootstrap tool compiler is build with a "go 1.20" go.mod, so
-// we are not allowed to use map clear yet. Use this helper instead.
-func genmapclear[KT comparable, VT any](m map[KT]VT) {
- for k := range m {
- delete(m, k)
- }
-}
-
type nameCount struct {
n *ir.Name
count int32
m.UnsafeVals = make(map[ssa.ID]bool)
m.UnsafeBlocks = make(map[ssa.ID]bool)
} else {
- for k := range m.Vals {
- delete(m.Vals, k)
- }
- for k := range m.UnsafeVals {
- delete(m.UnsafeVals, k)
- }
- for k := range m.UnsafeBlocks {
- delete(m.UnsafeBlocks, k)
- }
+ clear(m.Vals)
+ clear(m.UnsafeVals)
+ clear(m.UnsafeBlocks)
}
m.DeferReturn = objw.StackMapDontCare
}
// storeUse contains stores which are used by a subsequent store.
loadUse.clear()
storeUse.clear()
- // TODO(deparker): use the 'clear' builtin once compiler bootstrap minimum version is raised to 1.21.
- for k := range localAddrs {
- delete(localAddrs, k)
- }
+ clear(localAddrs)
stores = stores[:0]
for _, v := range b.Values {
if v.Op == OpPhi {
if state.varParts == nil {
state.varParts = make(map[*ir.Name][]SlotID)
} else {
- for n := range state.varParts {
- delete(state.varParts, n)
- }
+ clear(state.varParts)
}
// Recompose any decomposed variables, and establish the canonical
}
// Clear state.
- for _, vid := range e.cachedVals {
- delete(e.cache, vid)
- }
+ clear(e.cache)
e.cachedVals = e.cachedVals[:0]
- for k := range e.contents {
- delete(e.contents, k)
- }
+ clear(e.contents)
e.usedRegs = 0
e.uniqueRegs = 0
e.finalRegs = 0
}
s.curBlock = b
s.vars = map[ir.Node]*ssa.Value{}
- for n := range s.fwdVars {
- delete(s.fwdVars, n)
- }
+ clear(s.fwdVars)
}
// endBlock marks the end of generating code for the current block.