]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/ppc64: use MOVDU to update stack reg for leaf functions where possible
authorLynn Boger <laboger@linux.vnet.ibm.com>
Tue, 25 Apr 2017 21:13:52 +0000 (17:13 -0400)
committerLynn Boger <laboger@linux.vnet.ibm.com>
Wed, 26 Apr 2017 17:39:33 +0000 (17:39 +0000)
When the stack register is decremented to acquire stack space at
the beginning of a function, a MOVDU should be used so it is done
atomically, unless the size of the stack frame is too large for
that instruction.  The code to determine whether to use MOVDU
or MOVD was checking if the function was a leaf and always generating MOVD
when it was.  The choice of MOVD vs. MOVDU should only depend on the stack
frame size.  This fixes that problem.

Change-Id: I0e49c79036f1e8f7584179e1442b938fc6da085f
Reviewed-on: https://go-review.googlesource.com/41813
Reviewed-by: Michael Munday <munday@ca.ibm.com>
src/cmd/internal/obj/ppc64/obj9.go

index 25a7bbf79ab8f47035c2792f0cea337e3bd43bdd..72e02d39cf4cb5f5876a4d6695022aafc3fb5316 100644 (file)
@@ -498,9 +498,10 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
                        }
 
                        if autosize != 0 {
-                               // Make sure to save link register for non-empty frame, even if
-                               // it is a leaf function, so that traceback works.
-                               if c.cursym.Func.Text.Mark&LEAF == 0 && autosize >= -BIG && autosize <= BIG {
+                               // Save the link register and update the SP.  MOVDU is used unless
+                               // the frame size is too large.  The link register must be saved
+                               // even for non-empty leaf functions so that traceback works.
+                               if autosize >= -BIG && autosize <= BIG {
                                        // Use MOVDU to adjust R1 when saving R31, if autosize is small.
                                        q = obj.Appendp(q, c.newprog)
                                        q.As = AMOVD