]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.15] cmd/compile: don't short-circuit copies whose source is volatile
authorKeith Randall <khr@golang.org>
Thu, 7 Jan 2021 22:57:53 +0000 (14:57 -0800)
committerDmitri Shuralyov <dmitshur@golang.org>
Thu, 21 Jan 2021 21:44:47 +0000 (21:44 +0000)
commit27d5fccd2119099c70ab6a4418626beac7a97b4b
tree58dae4adc55089bed22402db88b6faa7537f8ab4
parente540758b604dd46b682593e284cf77a61ce3fde6
[release-branch.go1.15] cmd/compile: don't short-circuit copies whose source is volatile

Current optimization: When we copy a->b and then b->c, we might as well
copy a->c instead of b->c (then b might be dead and go away).

*Except* if a is a volatile location (might be clobbered by a call).
In that case, we really do want to copy a immediately, because there
might be a call before we can do the a->c copy.

User calls can't happen in between, because the rule matches up the
memory states. But calls inserted for memory barriers, particularly
runtime.typedmemmove, can.

(I guess we could introduce a register-calling-convention version
of runtime.typedmemmove, but that seems a bigger change than this one.)

Fixes #43575

Change-Id: Ifa518bb1a6f3a8dd46c352d4fd54ea9713b3eb1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/282492
Trust: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
(cherry picked from commit 304f769ffc68e64244266b3aadbf91e6738c0064)
Reviewed-on: https://go-review.googlesource.com/c/go/+/282558
Trust: Dmitri Shuralyov <dmitshur@golang.org>
src/cmd/compile/internal/ssa/gen/generic.rules
src/cmd/compile/internal/ssa/rewritegeneric.go
test/fixedbugs/issue43570.go [new file with mode: 0644]