Skip to content

cmd/compile, runtime: avoid improper control transfer instruction hin… - #146

Open
lxq015 wants to merge 1 commit into
go1.26.3-zte-devfrom
improper_control_transfer_instruction
Open

lxq015 wants to merge 1 commit into
go1.26.3-zte-devfrom
improper_control_transfer_instruction

Conversation

@lxq015

@lxq015 lxq015 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Add race_riscv64.s, which was absent when we cherry-picked Boyao's CL (https://go-review.googlesource.com/c/go/+/726760) into go1.25.6. This file is needed as we update to go1.26.3.

Updates #102

…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>
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