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

resource: Ignore debug insns in find_basic_block [PR127726]

Ensures debug instructions do not interfere with basic block analysis, preventing issues with live register tracking and delay slot filling.

This commit addresses an issue in the find_basic_block function where debug instructions were consuming the limited search budget for identifying preceding non-note instructions. This could lead to mark_target_live_regs incorrectly assuming all registers are live, potentially preventing ordinary instructions from filling delay slots. The fix modifies the function to ignore debug instructions, using non-debug neighbor helpers instead. This resolves a bug related to live register analysis and delay slot optimization, as verified by new SPARC test cases.

In Details

Updates resource.cc:find_basic_block to correctly handle debug instructions during its backward and forward scans for basic block boundaries. Previously, prev_nonnote_insn would return DEBUG_INSNs, causing these to consume the limited max-delay-slot-live-search budget. Exhausting this budget incorrectly marks all registers as live, hindering optimization opportunities like filling delay slots. The patch employs nondebug neighbor helpers for both scans, ensuring accurate live register analysis and preventing performance regressions caused by debug information artifacts.

For Context
basic block
A contiguous sequence of code with a single entry point and a single exit point. Compilers often analyze code at the basic block level.
debug insns
Instructions generated by the compiler specifically for debugging purposes, such as marking line numbers or variable scopes. These are typically discarded in optimized builds.
live register
A register whose value might be used in the future. Compilers track live registers to determine which registers can be reused without overwriting needed data.
delay slot
A CPU architectural feature where the instruction immediately following a branch or jump is executed regardless of whether the branch is taken. Optimizers try to fill this slot with useful work.
PR127726
Problem Report number 127726, indicating a bug filed against the GCC compiler related to resource analysis and optimization.
Filed Under: resource-analysisdebugoptimization