binutils Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
loongarch Performance Win

LoongArch: Use less DW_LNS_fixed_advance_pc

Optimizes DWARF location list generation for LoongArch by using DW_LNS_fixed_advance_pc conditionally.

This commit optimizes DWARF location list generation for LoongArch by conditionally using DW_LNS_fixed_advance_pc. Previously, this opcode was used even when linker relaxation was not involved between symbols. The change introduces finer control using FROM and TO symbols, employing DW_LNS_fixed_advance_pc only when linker-relaxable instructions are present, and using special opcodes otherwise. A new macro DWARF2_USE_FIXED_ADVANCE_PC_FRAG is added to prevent unnecessary calls for other targets.

In Details

This commit refines DWARF debugging information generation for LoongArch by optimizing the use of DW_LNS_fixed_advance_pc. It introduces logic to conditionally use this opcode based on the presence of linker-relaxable instructions between symbols. If such instructions exist, DW_LNS_fixed_advance_pc is used; otherwise, special opcodes are employed. This prevents unnecessary calls to symbol_get_value_expression on other targets via the new DWARF2_USE_FIXED_ADVANCE_PC_FRAG macro, improving efficiency and reducing DWARF output size.

For Context
LoongArch
A RISC-ISA developed by Loongson Technology, primarily for China, used in various processors.
DWARF
A debugging data format used by compilers to store information about variables, functions, and types, enabling debuggers to interpret program state.
DW_LNS_fixed_advance_pc
A DWARF Line Number Statement opcode that advances the Location Counter by a fixed amount, used for generating PC-relative location information.
linker relaxation
A process where the linker adjusts the addresses of code or data to optimize for short jump/call distances, especially in position-independent code (PIC) or position-independent executables (PIE).
symbol_get_value_expression
A function likely used within the assembler to retrieve the value or expression associated with a symbol, possibly related to DWARF information generation.
Filed Under: loongarchdwarfdebuggingoptimization