]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: enable PAUTO capture variables on arch != 6
authorRuss Cox <rsc@golang.org>
Mon, 29 Jun 2015 17:56:27 +0000 (13:56 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 29 Jun 2015 19:49:18 +0000 (19:49 +0000)
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>
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/x86/gsubr.go

index 601154b3467ead1f4442946293226abe75f8d534..24af94c0cda3a65c6161d4c15c2185858c18fa4e 100644 (file)
@@ -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))
index baf251781c2c88e581bf49d2ea829bf097de551e..7593d043bbe8e79a4742fbe5f7d763c4d5d44081 100644 (file)
@@ -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)