Ignore debug instructions in BARRIER checks for jump optimization
GCC's reorg pass now correctly ignores debug instructions when checking for BARRIERs before jump targets.
This commit modifies GCC’s reorg pass to ignore debug instructions when checking for BARRIERs that immediately precede jump targets. Previously, debug instructions could interfere with these checks, leading to incorrect analysis of code flow, especially after the pass_cleanup_barriers pass. The change introduces prev_nonnote_nondebug_insn for these checks and adds SPARC tests to cover the corrected logic.
In Details
The reorg pass, specifically relax_delay_slots, queries for a BARRIER preceding a jump target. The pass_cleanup_barriers can insert DEBUG_INSNs. The original query using prev_nonnote_insn would incorrectly stop at a DEBUG_INSN. This patch uses prev_nonnote_nondebug_insn to ensure the BARRIER check is accurate, preventing misanalysis of control flow and potential optimization errors related to delay slots.
- BARRIER
- An RTL (Register Transfer Language) instruction that signifies a point in the code where control flow is guaranteed to be discontinuous. It's used by the compiler to understand execution paths and optimize code.
- DEBUG_INSN
- An RTL instruction that represents debugging information, such as line number information or variable tracking data. These instructions are typically only present when the code is compiled with debugging flags.
- RTL
- Register Transfer Language, an intermediate representation used by GCC internally to represent code. It's a low-level, machine-independent representation that facilitates optimization.
- reorg pass
- A compiler pass in GCC that reorganizes RTL code for optimization purposes, often dealing with instruction scheduling and control flow.
- delay slots
- A characteristic of some processor architectures where the instruction immediately following a branch or jump instruction is executed regardless of whether the branch is taken. Compilers attempt to fill these slots with useful instructions to improve performance.