diff options
author | Than McIntosh <thanm@google.com> | 2021-04-05 16:50:38 -0400 |
---|---|---|
committer | Than McIntosh <thanm@google.com> | 2021-04-05 23:21:16 +0000 |
commit | b2389ad3ce7254784db5f4005805714e87ffab85 (patch) | |
tree | 5c4ce785e0b23ec6e3aa8ecb10c1a63b295ea783 /src/cmd/compile/internal/amd64 | |
parent | d446cb7cff024412c0a80c3971dac3049db9f18c (diff) | |
download | go-b2389ad3ce7254784db5f4005805714e87ffab85.tar.gz go-b2389ad3ce7254784db5f4005805714e87ffab85.zip |
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>
Diffstat (limited to 'src/cmd/compile/internal/amd64')
-rw-r--r-- | src/cmd/compile/internal/amd64/ggen.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/amd64/ggen.go b/src/cmd/compile/internal/amd64/ggen.go index e56ec90dc8..f065bb4dd4 100644 --- a/src/cmd/compile/internal/amd64/ggen.go +++ b/src/cmd/compile/internal/amd64/ggen.go @@ -58,6 +58,7 @@ func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, state *uint32) *obj. const ( r13 = 1 << iota // if R13 is already zeroed. x15 // if X15 is already zeroed. Note: in new ABI, X15 is always zero. + rax // if RAX is already zeroed. ) 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) } else { - if *state&r13 == 0 { - p = pp.Append(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_R13, 0) - *state |= r13 + // Note: here we have to use RAX since it is an implicit input + // for the REPSTOSQ below. This is going to be problematic when + // 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) |