]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.14] cmd/compile, runtime: mark R12 clobbered for write barrier...
authorCherry Zhang <cherryyz@google.com>
Mon, 17 Aug 2020 23:06:19 +0000 (19:06 -0400)
committerDmitri Shuralyov <dmitshur@golang.org>
Thu, 3 Sep 2020 14:49:10 +0000 (14:49 +0000)
commit652aebf5fc6de98bf5605df80403f04158260920
treec9085a009d961a2a25c4f31ebfbb9cc248cd75ca
parentdd953ded330bd3b859b2eae46af7b6600bfeedff
[release-branch.go1.14] cmd/compile, runtime: mark R12 clobbered for write barrier call on PPC64

When external linking, for large binaries, the external linker
may insert a trampoline for the write barrier call, which looks

0000000005a98cc8 <__long_branch_runtime.gcWriteBarrier>:
 5a98cc8:       86 01 82 3d     addis   r12,r2,390
 5a98ccc:       d8 bd 8c e9     ld      r12,-16936(r12)
 5a98cd0:       a6 03 89 7d     mtctr   r12
 5a98cd4:       20 04 80 4e     bctr

It clobbers R12 (and CTR, which is never live across a call).

As at compile time we don't know whether the binary is big and
what link mode will be used, I think we need to mark R12 as
clobbered for write barrier call. For extra safety (future-proof)
we mark caller-saved register that cannot be used for function
arguments, which includes R11, as potentially clobbered as well.

Updates #40851.
Fixes #40938.

Change-Id: Iedd901c5072f1127cc59b0a48cfeb4aaec81b519
Reviewed-on: https://go-review.googlesource.com/c/go/+/248917
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
(cherry picked from commit b58d29741650c7bf10b17f455666e2727e1cdd2e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/249697
src/cmd/compile/internal/ssa/gen/PPC64Ops.go
src/cmd/compile/internal/ssa/opGen.go
src/runtime/asm_ppc64x.s