diff options
author | David Chase <drchase@google.com> | 2021-04-08 12:44:05 -0400 |
---|---|---|
committer | David Chase <drchase@google.com> | 2021-04-08 20:26:47 +0000 |
commit | a9e475a15a7211c356157d1d0e5dc7cef7dd970e (patch) | |
tree | d26df7156a549a71bdb2148d9a7d39e3527f89e1 /src/cmd/compile/internal/ssa/value.go | |
parent | 7e583806d8135a59866ff329cc19a0bc4425aa80 (diff) | |
download | go-a9e475a15a7211c356157d1d0e5dc7cef7dd970e.tar.gz go-a9e475a15a7211c356157d1d0e5dc7cef7dd970e.zip |
cmd/compile: add recursive-invalidate Value method, use in expand_calls
This removes more unused values during transformation.
Leaving them in the tree can create type conflicts in OpArg* references.
Updates #40724.
Updates #44816.
Fixes #45417.
Change-Id: I07dcb7b4b2bf8d79e22e0543cb2fb52c2ececb96
Reviewed-on: https://go-review.googlesource.com/c/go/+/308589
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/value.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/value.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/value.go b/src/cmd/compile/internal/ssa/value.go index ba7f8c0300..630e4814b9 100644 --- a/src/cmd/compile/internal/ssa/value.go +++ b/src/cmd/compile/internal/ssa/value.go @@ -348,6 +348,35 @@ func (v *Value) reset(op Op) { v.Aux = nil } +// invalidateRecursively marks a value as invalid (unused) +// and after decrementing reference counts on its Args, +// also recursively invalidates any of those whose use +// count goes to zero. +// +// BEWARE of doing this *before* you've applied intended +// updates to SSA. +func (v *Value) invalidateRecursively() { + if v.InCache { + v.Block.Func.unCache(v) + } + v.Op = OpInvalid + + for _, a := range v.Args { + a.Uses-- + if a.Uses == 0 { + a.invalidateRecursively() + } + } + + v.argstorage[0] = nil + v.argstorage[1] = nil + v.argstorage[2] = nil + v.Args = v.argstorage[:0] + + v.AuxInt = 0 + v.Aux = nil +} + // copyOf is called from rewrite rules. // It modifies v to be (Copy a). //go:noinline |