Skip to content

Commit d198a36

Browse files
pmurcherrymui
authored andcommitted
cmd/asm,cmd/compile: fix tail call in leaf functions on PPC64
In some leaf functions using "RET foo(SB)", the jump may be incorrectly translated into "JMP LR" instead of "JMP foo(SB)". Such is the case when compiling the autogenerated function in k8s k8s.io/kubernetes/pkg/kubelet/server/stats.(*resourceAnalyzer).GetPodVolumeStats. Fixes #50048 Change-Id: Icdf65fcda6b3c5eb9d3ad5c7aad04add9419dffb Reviewed-on: https://go-review.googlesource.com/c/go/+/371034 Run-TryBot: Paul Murphy <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Trust: Paul Murphy <[email protected]>
1 parent f4ca598 commit d198a36

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/cmd/internal/obj/ppc64/obj9.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,13 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
884884
q = c.newprog()
885885
q.As = ABR
886886
q.Pos = p.Pos
887-
q.To.Type = obj.TYPE_REG
888-
q.To.Reg = REG_LR
887+
if retTarget == nil {
888+
q.To.Type = obj.TYPE_REG
889+
q.To.Reg = REG_LR
890+
} else {
891+
q.To.Type = obj.TYPE_BRANCH
892+
q.To.Sym = retTarget
893+
}
889894
q.Mark |= BRANCH
890895
q.Spadj = +autosize
891896

0 commit comments

Comments
 (0)