Skip to content

【DEBUG: DO NOT REVIEW】runtime, cmd/internal/obj/riscv: enable framepointer on riscv64 | https://go-review.googlesource.com/c/go/+/753022 - #145

Draft
lxq015 wants to merge 6 commits into
go1.26.3-zte-devfrom
enable_fp_rv
Draft

lxq015 wants to merge 6 commits into
go1.26.3-zte-devfrom
enable_fp_rv

Conversation

@lxq015

@lxq015 lxq015 commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

@lxq015
lxq015 marked this pull request as draft June 15, 2026 01:25
…ts on riscv64

On RISC-V the JAL and JALR instructions provide Return Address
Stack(RAS) prediction hints based on the registers used (as per section
2.5.1 of the RISC-V ISA manual). When a JALR instruction uses X1 or X5
as the source register, it hints that a pop should occur.

When making a function call, avoid the use of X5 as a source register
since this results in the RAS performing a pop-then-push instead of a
push, breaking call/return pairing and significantly degrading front-end
branch prediction performance.

Based on test result of golang.org/x/benchmarks/json on SpacemiT K1, fix
version has a performance improvement of about 7%

Fixes golang#76654

Change-Id: I867c8d7cfb54f5decbe176f3ab3bb3d78af1cf64
Reviewed-on: https://go-review.googlesource.com/c/go/+/726760
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
This CL implements hardware frame pointer support for riscv64.

The stack layout is similar to arm64, but with the following specifics:
- The FP register points to SP+8.
- The return address (LR) is stored at SP.
- The caller's FP is stored at SP-8.

Change-Id: I3bc7af2abb024ea0b0e3432ed517641c6707f7a2
lxq015 added 2 commits June 27, 2026 10:38
…tail for branch prediction on riscv64 (#136)"

This reverts commit 6092341.
lxq015 added 2 commits June 29, 2026 14:48
…unction tail for branch prediction on riscv64 (#136)""

This reverts commit 5e55a8a.
@lxq015 lxq015 changed the title runtime, cmd/internal/obj/riscv: enable framepointer on riscv64 | https://go-review.googlesource.com/c/go/+/753022 【DEBUG: DO NOT REVIEW】runtime, cmd/internal/obj/riscv: enable framepointer on riscv64 | https://go-review.googlesource.com/c/go/+/753022 Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants