]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: make sure address of offset(SP) is rematerializeable
authorCherry Zhang <cherryyz@google.com>
Thu, 3 Dec 2020 18:32:11 +0000 (13:32 -0500)
committerCherry Zhang <cherryyz@google.com>
Thu, 3 Dec 2020 21:34:39 +0000 (21:34 +0000)
commit37a32a1833a6e55baaa8d971406094148e42f7d1
tree9cbb7c2c0e7f47dd9928b79d1f8482b683e98121
parentb78b427be5e4c8a51a2b01b39c1ce6c4f39a93dc
cmd/compile: make sure address of offset(SP) is rematerializeable

An address of offset(SP) may point to the callee args area, and
may be used to move things into/out of the args/results. If an
address like that is spilled and picked up by the GC, it may hold
an arg/result live in the callee, which may not actually be live
(e.g. a result not initialized at function entry). Make sure
they are rematerializeable, so they are always short-lived and
never picked up by the GC.

This CL changes 386, PPC64, and Wasm. On AMD64 we already have
the rule (line 2159). On other architectures, we already have
similar rules like
(OffPtr [off] ptr:(SP)) => (MOVDaddr [int32(off)] ptr)
to avoid this problem. (Probably me in the past had run into
this...)

Fixes #42944.

Change-Id: Id2ec73ac08f8df1829a9a7ceb8f749d67fe86d1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/275174
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/gen/386.rules
src/cmd/compile/internal/ssa/gen/PPC64.rules
src/cmd/compile/internal/ssa/gen/Wasm.rules
src/cmd/compile/internal/ssa/rewrite386.go
src/cmd/compile/internal/ssa/rewritePPC64.go
src/cmd/compile/internal/ssa/rewriteWasm.go
src/cmd/compile/internal/wasm/ssa.go
test/fixedbugs/issue42944.go [new file with mode: 0644]