Skip to content

Commit 751c37f

Browse files
committed
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 <[email protected]> Reviewed-by: Joel Sing <[email protected]>
1 parent a8b28eb commit 751c37f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/cmd/internal/obj/arm/obj5.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,13 +487,15 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
487487
// If there are instructions following
488488
// this ARET, they come from a branch
489489
// with the same stackframe, so no spadj.
490+
490491
if p.To.Sym != nil { // retjmp
491492
p.To.Reg = REGLINK
492493
q2 = obj.Appendp(p, newprog)
493494
q2.As = AB
494495
q2.To.Type = obj.TYPE_BRANCH
495496
q2.To.Sym = p.To.Sym
496497
p.To.Sym = nil
498+
p.To.Name = obj.NAME_NONE
497499
p = q2
498500
}
499501

src/cmd/internal/obj/s390x/objz.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,10 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
497497
p.From.Type = obj.TYPE_MEM
498498
p.From.Reg = REGSP
499499
p.From.Offset = 0
500-
p.To.Type = obj.TYPE_REG
501-
p.To.Reg = REG_LR
500+
p.To = obj.Addr{
501+
Type: obj.TYPE_REG,
502+
Reg: REG_LR,
503+
}
502504

503505
q = p
504506

0 commit comments

Comments
 (0)