GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc

Use add_reg_note instead of hand-built notes.

Replace manual note creation with add_reg_note for consistency and correctness.

This commit refactors several machine-specific backends (arm, cris, frv, loongarch, riscv, stormy16) to use the add_reg_note function instead of manually constructing instruction notes. This promotes code consistency and leverages the internal add_reg_note’s handling of RTL structures. The changes primarily affect functions related to multi-register operations and epilogue emission, ensuring that register-related metadata is managed uniformly.

In Details

This commit consolidates the creation of register notes in multiple GCC backends by replacing custom code with calls to the generic add_reg_note function. This includes arm.cc, cris.cc, frv.cc, loongarch.cc, riscv.cc, and stormy16.cc. The motivation is to use the established add_reg_note mechanism, which correctly handles RTL node creation and linking, rather than potentially error-prone manual RTL manipulation for notes. This improves maintainability and correctness of instruction annotations.

For Context
add_reg_note
A GCC internal function used to add a note associated with a register, likely for tracking register usage, dependencies, or other metadata critical for optimization and code generation.
RTL
Register Transfer Language, an intermediate representation used by GCC to represent code between parsing and machine-specific code generation. It's a Lisp-like language of expressions.
backend
The part of the compiler that translates the intermediate representation into machine-specific code for a particular target architecture.
Filed Under: refactorrtl