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: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/src/cmd/compile/internal/gc/closure.go b/src/cmd/compile/internal/gc/closure.go index 601154b..24af94c 100644 --- a/src/cmd/compile/internal/gc/closure.go +++ b/src/cmd/compile/internal/gc/closure.go
@@ -382,12 +382,9 @@ 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))
diff --git a/src/cmd/compile/internal/x86/gsubr.go b/src/cmd/compile/internal/x86/gsubr.go index baf2517..7593d04 100644 --- a/src/cmd/compile/internal/x86/gsubr.go +++ b/src/cmd/compile/internal/x86/gsubr.go
@@ -556,7 +556,7 @@ 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 @@ 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)