Skip to content

Commit 694182d

Browse files
pmurgopherbot
authored andcommitted
cmd/internal/obj/ppc64: improve large prologue generation
Avoid needing an unsafe section to store LR and adjust SP for large constants by using the stdux (MOVDU) instruction. This is also a few instructions shorter as the large constant adjustment is only created once. Change-Id: I6ff7a24181cdadb1846a33129fc148dcf59b76d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/710197 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent b0dcb95 commit 694182d

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

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

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -903,44 +903,38 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
903903
q.To.Reg = REGSP
904904
q.Spadj = autosize
905905
} else {
906-
// Frame size is too large for a MOVDU instruction.
907-
// Store link register before decrementing SP, so if a signal comes
908-
// during the execution of the function prologue, the traceback
909-
// code will not see a half-updated stack frame.
910-
// This sequence is not async preemptible, as if we open a frame
911-
// at the current SP, it will clobber the saved LR.
906+
// Frame size is too large for an stdu MOVDU instruction, use stdux MOVDU.
912907
q = obj.Appendp(q, c.newprog)
913908
q.As = AMOVD
914909
q.Pos = p.Pos
915910
q.From.Type = obj.TYPE_REG
916911
q.From.Reg = REG_LR
917912
q.To.Type = obj.TYPE_REG
918-
q.To.Reg = REG_R29 // REGTMP may be used to synthesize large offset in the next instruction
919-
920-
q = c.ctxt.StartUnsafePoint(q, c.newprog)
913+
q.To.Reg = REG_R29
921914

915+
// Create stack adjustment in REGTMP
922916
q = obj.Appendp(q, c.newprog)
923917
q.As = AMOVD
924918
q.Pos = p.Pos
925-
q.From.Type = obj.TYPE_REG
926-
q.From.Reg = REG_R29
927-
q.To.Type = obj.TYPE_MEM
928-
q.To.Offset = int64(-autosize)
929-
q.To.Reg = REGSP
919+
q.From.Type = obj.TYPE_CONST
920+
q.From.Offset = int64(-autosize)
921+
q.To.Type = obj.TYPE_REG
922+
q.To.Reg = REGTMP
930923

931924
prologueEnd = q
932925

926+
// MOVDU R29, R31(R1)
933927
q = obj.Appendp(q, c.newprog)
934-
q.As = AADD
928+
q.As = AMOVDU
935929
q.Pos = p.Pos
936-
q.From.Type = obj.TYPE_CONST
937-
q.From.Offset = int64(-autosize)
938-
q.To.Type = obj.TYPE_REG
939-
q.To.Reg = REGSP
940-
q.Spadj = +autosize
941-
942-
q = c.ctxt.EndUnsafePoint(q, c.newprog, -1)
930+
q.From.Type = obj.TYPE_REG
931+
q.From.Reg = REG_R29
932+
q.To.Type = obj.TYPE_MEM
933+
q.To.Reg = REGTMP
934+
q.To.Index = REGSP
935+
q.Spadj = autosize
943936
}
937+
944938
prologueEnd.Pos = prologueEnd.Pos.WithXlogue(src.PosPrologueEnd)
945939
} else if c.cursym.Func().Text.Mark&LEAF == 0 {
946940
// A very few functions that do not return to their caller

0 commit comments

Comments
 (0)