Landing: 8404a2538d64

Project / Subsystem

gcc / risc-v

Date

2026-01-07

Author

Monk Chiang

Commit

8404a2538d64ea6c4abb59d9db59b19cb265af79

Source

github

Perf win

No

Breaking

No

All attributes

project
gcc
subsystem
risc-v
patch_id
commit_hash
8404a2538d64ea6c4abb59d9db59b19cb265af79
source_type
github
headline
RISC-V: Use long jumps when crossing section boundaries.
tldr
GCC now uses long jumps for RISC-V when jumping between code sections that may be far apart, preventing linker errors with -freorder-blocks-and-partition.
author
Monk Chiang
outcome
committed
performance_win
false
breaking_change
false
series_id
series_parts
[]
tags
  • risc-v
  • code generation
  • optimization
discussion_id_link
bugzilla_pr
date
2026-01-07T00:00:00.000Z

This patch addresses an issue in the RISC-V backend of GCC where jumps between different code sections (e.g., hot code in .text and cold code in .text.unlikely) could exceed the range of the JAL instruction when using -freorder-blocks-and-partition. To fix this, GCC now checks for cross-section jumps and uses the longer AUIPC+JALR instruction sequence (8 bytes) instead of the shorter JAL instruction (4 bytes) when necessary, ensuring that jumps can reach targets beyond the JAL instruction’s ±1MB range.