aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/value.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2020-06-30 15:59:40 -0700
committerKeith Randall <khr@golang.org>2020-08-27 22:56:29 +0000
commitcdc635547fc436dc49c91ddb172b0e101febd3d7 (patch)
tree28fd1c88a0df5e9f81d98e282e612b93e287689a /src/cmd/compile/internal/ssa/value.go
parent8247da36621986a282c96b2abc236bbda2fdef41 (diff)
downloadgo-cdc635547fc436dc49c91ddb172b0e101febd3d7.tar.gz
go-cdc635547fc436dc49c91ddb172b0e101febd3d7.zip
cmd/compile: invalidate zero-use values during rewrite
This helps remove uses that aren't needed any more. That in turn helps other rules with Uses==1 conditions fire. Update #39918 Change-Id: I68635b675472f1d59e59604e4d34b949a0016533 Reviewed-on: https://go-review.googlesource.com/c/go/+/249463 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/value.go')
-rw-r--r--src/cmd/compile/internal/ssa/value.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/value.go b/src/cmd/compile/internal/ssa/value.go
index 7ead0ff300..7fc33772d3 100644
--- a/src/cmd/compile/internal/ssa/value.go
+++ b/src/cmd/compile/internal/ssa/value.go
@@ -460,3 +460,23 @@ func (v *Value) LackingPos() bool {
return v.Op == OpVarDef || v.Op == OpVarKill || v.Op == OpVarLive || v.Op == OpPhi ||
(v.Op == OpFwdRef || v.Op == OpCopy) && v.Type == types.TypeMem
}
+
+// removeable reports whether the value v can be removed from the SSA graph entirely
+// if its use count drops to 0.
+func (v *Value) removeable() bool {
+ if v.Type.IsVoid() {
+ // Void ops, like nil pointer checks, must stay.
+ return false
+ }
+ if v.Type.IsMemory() {
+ // All memory ops aren't needed here, but we do need
+ // to keep calls at least (because they might have
+ // syncronization operations we can't see).
+ return false
+ }
+ if v.Op.HasSideEffects() {
+ // These are mostly synchronization operations.
+ return false
+ }
+ return true
+}