Commit 27edd720 authored by Russ Cox's avatar Russ Cox

cmd/compile: enable PAUTO capture variables on arch != 6

Fixes #9865.

Change-Id: I8ce5b1708ed938910c59899706e470271c2e7e9d
Reviewed-on: https://go-review.googlesource.com/11699
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 2814906d
......@@ -382,12 +382,9 @@ func transformclosure(xfunc *Node) {
cv.Xoffset = offset
offset += cv.Type.Width
if v.Name.Byval && v.Type.Width <= int64(2*Widthptr) && Thearch.Thechar == '6' {
// If it is a small variable captured by value, downgrade it to PAUTO.
// This optimization is currently enabled only for amd64, see:
// https://github.com/golang/go/issues/9865
if v.Name.Byval && v.Type.Width <= int64(2*Widthptr) {
// If it is a small variable captured by value, downgrade it to PAUTO.
v.Class = PAUTO
v.Ullman = 1
xfunc.Func.Dcl = list(xfunc.Func.Dcl, v)
body = list(body, Nod(OAS, v, cv))
......
......@@ -556,7 +556,7 @@ var resvd = []int{
x86.REG_AX, // for divide
x86.REG_CX, // for shift
x86.REG_DX, // for divide
x86.REG_DX, // for divide, context
x86.REG_SP, // for stack
}
......@@ -909,10 +909,13 @@ func gmove(f *gc.Node, t *gc.Node) {
gins(x86.AMOVL, &flo, &tlo)
gins(x86.AMOVL, &fhi, &thi)
} else {
// Implementation of conversion-free x = y for int64 or uint64 x.
// This is generated by the code that copies small values out of closures,
// and that code has DX live, so avoid DX and use CX instead.
var r1 gc.Node
gc.Nodreg(&r1, gc.Types[gc.TUINT32], x86.REG_AX)
var r2 gc.Node
gc.Nodreg(&r2, gc.Types[gc.TUINT32], x86.REG_DX)
gc.Nodreg(&r2, gc.Types[gc.TUINT32], x86.REG_CX)
gins(x86.AMOVL, &flo, &r1)
gins(x86.AMOVL, &fhi, &r2)
gins(x86.AMOVL, &r1, &tlo)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment