From a5e3cac89587d2d6235e9a7217185dee9be6852a Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 15 Mar 2017 11:15:13 -0700 Subject: cmd/compile: rearrange fields between ssa.Func, ssa.Cache, and ssa.Config This makes ssa.Func, ssa.Cache, and ssa.Config fulfill the roles laid out for them in CL 38160. The only non-trivial change in this CL is how cached values and blocks get IDs. Prior to this CL, their IDs were assigned as part of resetting the cache, and only modified IDs were reset. This required knowing how many values and blocks were modified, which required a tight coupling between ssa.Func and ssa.Config. To eliminate that coupling, we now zero values and blocks during reset, and assign their IDs when they are used. Since unused values and blocks have ID == 0, we can efficiently find the last used value/block, to avoid zeroing everything. Bulk zeroing is efficient, but not efficient enough to obviate the need to avoid zeroing everything every time. As a happy side-effect, ssa.Func.Free is no longer necessary. DebugHashMatch and friends now belong in func.go. They have been left in place for clarity and review. I will move them in a subsequent CL. Passes toolstash -cmp. No compiler performance impact. No change in 'go test cmd/compile/internal/ssa' execution time. Change-Id: I2eb7af58da067ef6a36e815a6f386cfe8634d098 Reviewed-on: https://go-review.googlesource.com/38167 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- src/cmd/compile/internal/ssa/stackalloc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/cmd/compile/internal/ssa/stackalloc.go') diff --git a/src/cmd/compile/internal/ssa/stackalloc.go b/src/cmd/compile/internal/ssa/stackalloc.go index cdc40e5a35..40edfc55c6 100644 --- a/src/cmd/compile/internal/ssa/stackalloc.go +++ b/src/cmd/compile/internal/ssa/stackalloc.go @@ -35,7 +35,7 @@ type stackAllocState struct { } func newStackAllocState(f *Func) *stackAllocState { - s := f.Config.stackAllocState + s := f.Cache.stackAllocState if s == nil { return new(stackAllocState) } @@ -61,7 +61,7 @@ func putStackAllocState(s *stackAllocState) { for i := range s.used { s.used[i] = false } - s.f.Config.stackAllocState = s + s.f.Cache.stackAllocState = s s.f = nil s.live = nil s.nArgSlot, s.nNotNeed, s.nNamedSlot, s.nReuse, s.nAuto, s.nSelfInterfere = 0, 0, 0, 0, 0, 0 -- cgit v1.3-5-g9baa