mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: fix for zerorange on plan9-amd64
In CL 305829 a problematic change was made to the compiler's amd64-specific "zerorange" function. In zerorange the compiler uses different sets of strategies depending on the size of the stack frame it needs to zero; turns out that only on plan9-amd64 was it hitting the final fallback strategy, which is a REPSTOSQ instruction. REPSTOSQ takes RAX as an input, hence the changes made in CL 305829 (switching to R13) were incorrect. This patch restores the zerorange REPSTOSQ sequence (back to use RAX). This is going to be an interim solution, since long term we need to avoid touching RAX in the function prolog (since if the new register ABI is in effect, it will hold a live value). Fixes #45372. Change-Id: Ic89a6a2a76d6e03b9fbda99275101e96b70fdf5d Reviewed-on: https://go-review.googlesource.com/c/go/+/307469 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David du Colombier <0intro@gmail.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
d446cb7cff
commit
b2389ad3ce
1 changed files with 7 additions and 3 deletions
|
|
@ -58,6 +58,7 @@ func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, state *uint32) *obj.
|
||||||
const (
|
const (
|
||||||
r13 = 1 << iota // if R13 is already zeroed.
|
r13 = 1 << iota // if R13 is already zeroed.
|
||||||
x15 // if X15 is already zeroed. Note: in new ABI, X15 is always zero.
|
x15 // if X15 is already zeroed. Note: in new ABI, X15 is always zero.
|
||||||
|
rax // if RAX is already zeroed.
|
||||||
)
|
)
|
||||||
|
|
||||||
if cnt == 0 {
|
if cnt == 0 {
|
||||||
|
|
@ -116,9 +117,12 @@ func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, state *uint32) *obj.
|
||||||
p = pp.Append(p, x86.AMOVQ, obj.TYPE_REG, x86.REG_R12, 0, obj.TYPE_REG, x86.REG_DI, 0)
|
p = pp.Append(p, x86.AMOVQ, obj.TYPE_REG, x86.REG_R12, 0, obj.TYPE_REG, x86.REG_DI, 0)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if *state&r13 == 0 {
|
// Note: here we have to use RAX since it is an implicit input
|
||||||
p = pp.Append(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_R13, 0)
|
// for the REPSTOSQ below. This is going to be problematic when
|
||||||
*state |= r13
|
// regabi is in effect; this will be fixed in a forthcoming CL.
|
||||||
|
if *state&rax == 0 {
|
||||||
|
p = pp.Append(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
|
||||||
|
*state |= rax
|
||||||
}
|
}
|
||||||
|
|
||||||
p = pp.Append(p, x86.AMOVQ, obj.TYPE_CONST, 0, cnt/int64(types.RegSize), obj.TYPE_REG, x86.REG_CX, 0)
|
p = pp.Append(p, x86.AMOVQ, obj.TYPE_CONST, 0, cnt/int64(types.RegSize), obj.TYPE_REG, x86.REG_CX, 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue