From: Russ Cox Date: Mon, 29 Jun 2015 17:56:27 +0000 (-0400) Subject: cmd/compile: enable PAUTO capture variables on arch != 6 X-Git-Tag: go1.5beta1~51 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=27edd7209e1c21fdd5143a725c91719791e9f1f5;p=gostls13.git 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 Reviewed-by: Brad Fitzpatrick --- diff --git a/src/cmd/compile/internal/gc/closure.go b/src/cmd/compile/internal/gc/closure.go index 601154b346..24af94c0cd 100644 --- a/src/cmd/compile/internal/gc/closure.go +++ b/src/cmd/compile/internal/gc/closure.go @@ -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)) diff --git a/src/cmd/compile/internal/x86/gsubr.go b/src/cmd/compile/internal/x86/gsubr.go index baf251781c..7593d043bb 100644 --- a/src/cmd/compile/internal/x86/gsubr.go +++ b/src/cmd/compile/internal/x86/gsubr.go @@ -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)