Commit 1e0ef660 authored by Cherry Zhang's avatar Cherry Zhang

cmd/internal/obj/mips: use LR as temporary register in RET

On mips/mips64, for non-leaf function, RET is assembled as
	MOV (SP), R4       // load saved LR
	ADD $framesize, SP
	JMP (R4)

This clobbers R4 unnecessarily. Use the link register as
temporary instead.

Probably for Go 1.11.

Change-Id: I2209db7be11074ed2e0e0829cace95ebfb709e9f
Reviewed-on: https://go-review.googlesource.com/79016
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: 's avatarAustin Clements <austin@google.com>
parent 36951a9f
......@@ -495,10 +495,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
p.From.Offset = 0
p.From.Reg = REGSP
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R4
if retSym != nil { // retjmp from non-leaf, need to restore LINK register
p.To.Reg = REGLINK
}
p.To.Reg = REGLINK
if autosize != 0 {
q = c.newprog()
......@@ -524,7 +521,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
} else {
q1.To.Type = obj.TYPE_MEM
q1.To.Offset = 0
q1.To.Reg = REG_R4
q1.To.Reg = REGLINK
}
q1.Mark |= BRANCH
q1.Spadj = +autosize
......
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