LoongArch: Do not emit relocation if addsy and subsy are in the same frag
Optimizes LoongArch assembly by consolidating relaxed instructions and alignment nops within a single fragment, thus avoiding redundant relocations for addsy/s…
This patch modifies the LoongArch assembler to place relaxed instructions and alignment nops within the same fragment. Consequently, if addsy and subsy (likely related to symbol address calculations) reside in the same fragment, the assembler will not emit relocations for them, reducing overhead.
- proposer
Proposes to group relaxed instructions and alignment nops into a single fragment for LoongArch, preventing relocation emission for addsy/subsy pairs within the same frag.
“Let relaxed instructions and alignment nops in a single frag. Do not emit relocation if addsy and subsy are in the same frag.”
In Details
This patch for LoongArch's gas aims to reduce unnecessary relocations during linker relaxation. It achieves this by ensuring that 'relaxed' instructions and 'alignment nops' (no-operation instructions used for padding) are grouped together within the same assembler fragment. When addsy (likely 'add symbol') and subsy (likely 'subtract symbol') operations, which often involve address calculations, occur within such a consolidated fragment, the assembler now avoids generating relocations for them. This optimization simplifies the output and can improve linker performance.
- LoongArch
- A RISC-V-based instruction set architecture developed by Loongson Technology.
- relaxed instructions
- Instructions whose final encoding or address in the object file can change after the initial assembly pass, often due to linker relaxation.
- alignment nops
- No-operation instructions used specifically to pad code or data to meet alignment requirements, which can affect instruction fetching and execution efficiency.
- frag
- A 'fragment', a basic unit of code or data within an assembler's intermediate representation, which eventually forms part of an object file section.
- relocation
- Information in an object file that describes how to modify addresses and references when the code is linked or loaded into memory.
- addsy/subsy
- Assembly pseudo-instructions or directives used in LoongArch to define symbols or perform address calculations, likely related to 'add symbol' and 'subtract symbol' operations.