From c938051dd0b80a5c60572d6807270d06ca685d2e Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Tue, 7 Oct 2025 07:58:50 -0700 Subject: Revert "cmd/compile: redo arm64 LR/FP save and restore" This reverts commit 719dfcf8a8478d70360bf3c34c0e920be7b32994. Reason for revert: Causing crashes. Change-Id: I0b8526dd03d82fa074ce4f97f1789eeac702b3eb Reviewed-on: https://go-review.googlesource.com/c/go/+/709755 Reviewed-by: Keith Randall Reviewed-by: David Chase LUCI-TryBot-Result: Go LUCI Auto-Submit: Keith Randall Reviewed-by: Cherry Mui --- src/runtime/stack.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/runtime/stack.go') diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 5eaceec6da..55e97e77af 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -579,27 +579,23 @@ var ptrnames = []string{ // | args to callee | // +------------------+ <- frame->sp // -// (arm64) +// (arm) // +------------------+ // | args from caller | // +------------------+ <- frame->argp -// | | -// +------------------+ <- frame->fp (aka caller's sp) -// | return address | +// | caller's retaddr | // +------------------+ -// | caller's FP | (frame pointer always enabled: TODO) +// | caller's FP (*) | (*) on ARM64, if framepointer_enabled && varp > sp // +------------------+ <- frame->varp // | locals | // +------------------+ // | args to callee | // +------------------+ -// | | +// | return address | // +------------------+ <- frame->sp // // varp > sp means that the function has a frame; // varp == sp means frameless function. -// -// Alignment padding, if needed, will be between "locals" and "args to callee". type adjustinfo struct { old stack @@ -713,8 +709,7 @@ func adjustframe(frame *stkframe, adjinfo *adjustinfo) { } // Adjust saved frame pointer if there is one. - if goarch.ArchFamily == goarch.AMD64 && frame.argp-frame.varp == 2*goarch.PtrSize || - goarch.ArchFamily == goarch.ARM64 && frame.argp-frame.varp == 3*goarch.PtrSize { + if (goarch.ArchFamily == goarch.AMD64 || goarch.ArchFamily == goarch.ARM64) && frame.argp-frame.varp == 2*goarch.PtrSize { if stackDebug >= 3 { print(" saved bp\n") } @@ -728,7 +723,10 @@ func adjustframe(frame *stkframe, adjinfo *adjustinfo) { throw("bad frame pointer") } } - // This is the caller's frame pointer saved in the current frame. + // On AMD64, this is the caller's frame pointer saved in the current + // frame. + // On ARM64, this is the frame pointer of the caller's caller saved + // by the caller in its frame (one word below its SP). adjustpointer(adjinfo, unsafe.Pointer(frame.varp)) } -- cgit v1.3-5-g9baa