From d198a36d8c1d0a251449a1cc2355485a177310c4 Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Fri, 10 Dec 2021 16:58:43 -0600 Subject: [PATCH] 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 Reviewed-by: Cherry Mui Trust: Paul Murphy --- src/cmd/internal/obj/ppc64/obj9.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cmd/internal/obj/ppc64/obj9.go b/src/cmd/internal/obj/ppc64/obj9.go index 7ac6465a72..c986c0d2b6 100644 --- a/src/cmd/internal/obj/ppc64/obj9.go +++ b/src/cmd/internal/obj/ppc64/obj9.go @@ -884,8 +884,13 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { q = c.newprog() q.As = ABR q.Pos = p.Pos - q.To.Type = obj.TYPE_REG - q.To.Reg = REG_LR + if retTarget == nil { + q.To.Type = obj.TYPE_REG + q.To.Reg = REG_LR + } else { + q.To.Type = obj.TYPE_BRANCH + q.To.Sym = retTarget + } q.Mark |= BRANCH q.Spadj = +autosize -- 2.48.1