go/ssa: opt: avoid an allocation
In the dom tree traversal, the final child of each node now inherits the parent's renaming map, reducing garbage. This reduces allocations by 1.4% and bytes allocated by 2.0% when building SSA for the entire standard library. Change-Id: Id19b6d6766b3e0bf32d1db1238eff8a42d11b242 Reviewed-on: https://go-review.googlesource.com/45833 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
f2cd9d3b51
commit
365911de24
|
@ -630,10 +630,15 @@ func rename(u *BasicBlock, renaming []Value, newPhis newPhiMap) {
|
||||||
|
|
||||||
// Continue depth-first recursion over domtree, pushing a
|
// Continue depth-first recursion over domtree, pushing a
|
||||||
// fresh copy of the renaming map for each subtree.
|
// fresh copy of the renaming map for each subtree.
|
||||||
for _, v := range u.dom.children {
|
for i, v := range u.dom.children {
|
||||||
// TODO(adonovan): opt: avoid copy on final iteration; use destructive update.
|
r := renaming
|
||||||
r := make([]Value, len(renaming))
|
if i < len(u.dom.children)-1 {
|
||||||
copy(r, renaming)
|
// On all but the final iteration, we must make
|
||||||
|
// a copy to avoid destructive update.
|
||||||
|
r = make([]Value, len(renaming))
|
||||||
|
copy(r, renaming)
|
||||||
|
}
|
||||||
rename(v, r, newPhis)
|
rename(v, r, newPhis)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue