Skip to content

Commit 039d455

Browse files
committed
cmd/compile: don't use duffzero on Plan 9
In CL 14408, the implementation of duffzero on amd64 was changed to replace the use of the MOVQ instructions by MOVUPS. However, it broke the build on plan9/amd64, since Plan 9 doesn't allow floating point in note handler. This change disables the use of duffzero on Plan 9. We also take care to not use the MOVUPS instruction. Fixes #14471. Change-Id: I8277b485dfe65a68d7d8338e52a048c5d45069bf Reviewed-on: https://go-review.googlesource.com/19890 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
1 parent a858931 commit 039d455

File tree

1 file changed

+22
-4
lines changed
  • src/cmd/compile/internal/amd64

1 file changed

+22
-4
lines changed

src/cmd/compile/internal/amd64/ggen.go

+22-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import (
1010
"cmd/internal/obj/x86"
1111
)
1212

13+
// no floating point in note handlers on Plan 9
14+
var isPlan9 = obj.Getgoos() == "plan9"
15+
1316
func defframe(ptxt *obj.Prog) {
1417
var n *gc.Node
1518

@@ -126,7 +129,7 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64, ax *uint32, x0 *uin
126129
*ax = 1
127130
}
128131
p = appendpp(p, x86.AMOVQ, obj.TYPE_REG, x86.REG_AX, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo)
129-
} else if cnt <= int64(8*gc.Widthreg) {
132+
} else if !isPlan9 && cnt <= int64(8*gc.Widthreg) {
130133
if *x0 == 0 {
131134
p = appendpp(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_REG, x86.REG_X0, 0)
132135
*x0 = 1
@@ -139,12 +142,11 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64, ax *uint32, x0 *uin
139142
if cnt%16 != 0 {
140143
p = appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo+cnt-int64(16))
141144
}
142-
} else if !gc.Nacl && (cnt <= int64(128*gc.Widthreg)) {
145+
} else if !gc.Nacl && !isPlan9 && (cnt <= int64(128*gc.Widthreg)) {
143146
if *x0 == 0 {
144147
p = appendpp(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_REG, x86.REG_X0, 0)
145148
*x0 = 1
146149
}
147-
148150
p = appendpp(p, leaptr, obj.TYPE_MEM, x86.REG_SP, frame+lo+dzDI(cnt), obj.TYPE_REG, x86.REG_DI, 0)
149151
p = appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_ADDR, 0, dzOff(cnt))
150152
p.To.Sym = gc.Linksym(gc.Pkglookup("duffzero", gc.Runtimepkg))
@@ -563,7 +565,7 @@ func clearfat(nl *gc.Node) {
563565

564566
w := nl.Type.Width
565567

566-
if w > 1024 || (gc.Nacl && w >= 64) {
568+
if w > 1024 || (w >= 64 && (gc.Nacl || isPlan9)) {
567569
var oldn1 gc.Node
568570
var n1 gc.Node
569571
savex(x86.REG_DI, &n1, &oldn1, nil, gc.Types[gc.Tptr])
@@ -630,6 +632,22 @@ func clearfat(nl *gc.Node) {
630632
}
631633

632634
func clearfat_tail(n1 *gc.Node, b int64) {
635+
if b >= 16 && isPlan9 {
636+
var z gc.Node
637+
gc.Nodconst(&z, gc.Types[gc.TUINT64], 0)
638+
q := b / 8
639+
for ; q > 0; q-- {
640+
n1.Type = z.Type
641+
gins(x86.AMOVQ, &z, n1)
642+
n1.Xoffset += 8
643+
b -= 8
644+
}
645+
if b != 0 {
646+
n1.Xoffset -= 8 - b
647+
gins(x86.AMOVQ, &z, n1)
648+
}
649+
return
650+
}
633651
if b >= 16 {
634652
var vec_zero gc.Node
635653
gc.Regalloc(&vec_zero, gc.Types[gc.TFLOAT64], nil)

0 commit comments

Comments
 (0)