cmd/internal/obj/{arm,s390x}: make return jump print nicer

When a function with non-zero frame size makes a return jump
(RET target), it assembles to, conceptually,

MOV (SP), LR
ADD $framesize, SP
JMP target

We did not clear some fields in the first instruction's Prog.To,
causing it printed like (on ARM)

MOVW.P	4(R13), (R14)(R14)(REG)

Clear the fields to make it print nicer.

Change-Id: I180901aeea41f1ff287d7c6034a6d69005927744
Reviewed-on: https://go-review.googlesource.com/c/go/+/264343
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
This commit is contained in:
Cherry Zhang 2020-10-21 21:29:43 -04:00
parent a8b28ebc87
commit 751c37fd62
2 changed files with 6 additions and 2 deletions

View File

@ -487,6 +487,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
// If there are instructions following
// this ARET, they come from a branch
// with the same stackframe, so no spadj.
if p.To.Sym != nil { // retjmp
p.To.Reg = REGLINK
q2 = obj.Appendp(p, newprog)
@ -494,6 +495,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
q2.To.Type = obj.TYPE_BRANCH
q2.To.Sym = p.To.Sym
p.To.Sym = nil
p.To.Name = obj.NAME_NONE
p = q2
}

View File

@ -497,8 +497,10 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
p.From.Type = obj.TYPE_MEM
p.From.Reg = REGSP
p.From.Offset = 0
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_LR
p.To = obj.Addr{
Type: obj.TYPE_REG,
Reg: REG_LR,
}
q = p