cmd/compile: reduce allocations in prove by reusing posets

In prove, reuse posets between different functions by storing them
in the per-worker cache.

Allocation count regression caused by prove improvements is down
from 5% to 3% after this CL.

Updates #25179

Change-Id: I6d14003109833d9b3ef5165fdea00aa9c9e952e8
Reviewed-on: https://go-review.googlesource.com/110455
Run-TryBot: Giovanni Bajo <rasky@develer.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Giovanni Bajo 2018-05-01 00:57:57 +02:00
parent 67656ba71b
commit 3c8545c5f6
5 changed files with 48 additions and 11 deletions

View file

@ -152,13 +152,8 @@ type poset struct {
undo []posetUndo // undo chain
}
func newPoset(unsigned bool) *poset {
var flags uint8
if unsigned {
flags |= posetFlagUnsigned
}
func newPoset() *poset {
return &poset{
flags: flags,
values: make(map[ID]uint32),
constants: make([]*Value, 0, 8),
nodes: make([]posetNode, 1, 16),
@ -168,6 +163,14 @@ func newPoset(unsigned bool) *poset {
}
}
func (po *poset) SetUnsigned(uns bool) {
if uns {
po.flags |= posetFlagUnsigned
} else {
po.flags &^= posetFlagUnsigned
}
}
// Handle children
func (po *poset) setchl(i uint32, l posetEdge) { po.nodes[i].l = l }
func (po *poset) setchr(i uint32, r posetEdge) { po.nodes[i].r = r }