1
0
mirror of https://github.com/golang/go synced 2024-11-19 18:44:41 -07:00

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: Austin Clements <austin@google.com>
This commit is contained in:
Cherry Zhang 2017-11-21 09:25:29 -05:00
parent 36951a9f63
commit 1e0ef6601d

View File

@ -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