]> Cypherpunks repositories - gostls13.git/commit
cmd/compile,cmd/internal/obj/riscv: move g register on riscv64
authorJoel Sing <joel@sing.id.au>
Tue, 19 May 2020 08:55:31 +0000 (18:55 +1000)
committerJoel Sing <joel@sing.id.au>
Wed, 21 Oct 2020 16:40:47 +0000 (16:40 +0000)
commit6f45b39e4dbabf0b179a60ffacf434e55b2d5eab
tree2511d4eef80169dedf5b6b9c892dba6e9eddc1bb
parent214136b7412d56151d5443741feb0ed873facf2e
cmd/compile,cmd/internal/obj/riscv: move g register on riscv64

The original riscv64 port used the thread pointer (TP aka X4) register for
the g pointer, however this register is also used when TLS support is
required, resulting in a conflict (for example, when a signal is received
we have no way of readily knowing if X4 contains a pointer to the TCB or
a pointer to a g).

In order to support cgo, free up the X4 register by moving g to X27.
This unfortunately means that the X4 register is unused in non-cgo mode,
however the alternative is to not support cgo on this platform.

Update #36641

Change-Id: Idcaf3e8ccbe42972a1b8943aeefde7149d9c960a
Reviewed-on: https://go-review.googlesource.com/c/go/+/263477
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssa/gen/RISCV64Ops.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/internal/obj/riscv/cpu.go
src/runtime/asm_riscv64.s