Commit 6910e108 authored by Lynn Boger's avatar Lynn Boger

cmd/internal/obj/ppc64: use MOVDU to update stack reg for leaf functions where possible

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/41813Reviewed-by: 's avatarMichael Munday <munday@ca.ibm.com>
parent 386765af
......@@ -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
......
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