diff options
author | Josh Bleecher Snyder <josharian@gmail.com> | 2019-10-30 10:29:47 -0700 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2020-03-02 16:24:47 +0000 |
commit | d7c073ecbfc3ecc506bfc753b271973b47f8bc15 (patch) | |
tree | 758702abba542e9b9c72a178e8ec34954e136fe5 /src/cmd/compile/internal/ssa/value.go | |
parent | ab7ecea0c8dff908dfcad8c9091b71c6051bb94a (diff) | |
download | go-d7c073ecbfc3ecc506bfc753b271973b47f8bc15.tar.gz go-d7c073ecbfc3ecc506bfc753b271973b47f8bc15.zip |
cmd/compile: add specialized Value reset for OpCopy
This:
* Simplifies and shortens the generated code for rewrite rules.
* Shrinks cmd/compile by 86k (0.4%) and makes it easier to compile.
* Removes the stmt boundary code wrangling from Value.reset,
in favor of doing it in the one place where it actually does some work,
namely the writebarrier pass. (This was ascertained by inspecting the
code for cases in which notStmtBoundary values were generated.)
Passes toolstash-check -all.
Change-Id: I25671d4c4bbd772f235195d11da090878ea2cc07
Reviewed-on: https://go-review.googlesource.com/c/go/+/221421
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/value.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/value.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/ssa/value.go b/src/cmd/compile/internal/ssa/value.go index 8c5834d530..e5246779fc 100644 --- a/src/cmd/compile/internal/ssa/value.go +++ b/src/cmd/compile/internal/ssa/value.go @@ -310,17 +310,29 @@ func (v *Value) resetArgs() { v.Args = v.argstorage[:0] } +// reset is called from most rewrite rules. +// Allowing it to be inlined increases the size +// of cmd/compile by almost 10%, and slows it down. +//go:noinline func (v *Value) reset(op Op) { v.Op = op - if op != OpCopy && notStmtBoundary(op) { - // Special case for OpCopy because of how it is used in rewrite - v.Pos = v.Pos.WithNotStmt() - } v.resetArgs() v.AuxInt = 0 v.Aux = nil } +// copyOf is called from rewrite rules. +// It modifies v to be (Copy a). +//go:noinline +func (v *Value) copyOf(a *Value) { + v.Op = OpCopy + v.resetArgs() + v.AddArg(a) + v.AuxInt = 0 + v.Aux = nil + v.Type = a.Type +} + // copyInto makes a new value identical to v and adds it to the end of b. // unlike copyIntoWithXPos this does not check for v.Pos being a statement. func (v *Value) copyInto(b *Block) *Value { |