Pass a const rtx_insn * to the reg-note finders
Improves RTL analysis by passing const rtx_insn* to register note finder functions.
This commit refactors several functions within GCC’s RTL analysis and scheduling components to accept a const rtx_insn * parameter. By marking the instruction pointer as constant, these functions can now operate on instructions that are not intended to be modified, improving code safety and potentially enabling further optimizations that rely on instruction immutability.
In Details
Functions such as find_reg_note, find_regno_note, find_reg_fusage, and find_regno_fusage in rtl.h and rtlanal.cc, as well as related functions in sched-deps.cc, except.cc, and resource.cc, have been updated to take a const rtx_insn * instead of a non-const rtx_insn *. This change reflects the fact that these functions only inspect instruction notes and do not modify the instruction itself, enhancing type safety and clarity within the RTL analysis passes.
- rtx_insn
- A data structure in GCC's internal representation (RTL) that represents a machine instruction.
- RTL
- Register Transfer Language, an intermediate representation used by GCC to represent programs after optimization but before code generation.
- const
- A keyword in C/C++ that indicates a variable or pointer cannot be modified after initialization. Using 'const' improves type safety and can enable compiler optimizations.
- reg-note
- A note attached to an RTX instruction that provides information about register usage, such as which registers are read, written, or clobbered.
- scheduling
- The process of reordering instructions to improve performance, typically by maximizing instruction-level parallelism and minimizing pipeline stalls.