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

Copy exception region notes to all calls, regardless of throw capability.

Ensures exception region notes are copied to all calls, fixing basic block errors and segfaults.

This commit fixes a bug where REG_EH_REGION notes, which indicate exception handling regions, were not copied to all new calls if the function could not throw exceptions. This omission led to compiler errors like ‘flow control insn inside a basic block’ and segfaults in specific scenarios, particularly with optimized code and non-local labels. The change ensures these notes are copied to every new call, regardless of its throw capability, maintaining correct basic block integrity and preventing runtime issues.

In Details

The except subsystem manages exception handling information via REG_EH_REGION notes on RTL insns. Previously, copy_reg_eh_region_note_forward/backward incorrectly skipped calls without exception-throwing capability (i.e., without a non-INT_MIN note). This led to dropped notes, breaking basic block validation (rtl_verify_bb_insns) when non-local labels were present, as calls without notes were treated as potential non-local goto targets. This commit modifies the copy functions to always copy the note to new calls, ensuring consistency with GIMPLE-expanded calls and libcalls that already receiv…

For Context
REG_EH_REGION
An RTL (Register Transfer Language) note attached to an instruction that specifies the range of instructions covered by an exception handler. This is crucial for correctly unwinding the stack during exception propagation.
RTL insn
An instruction in the Register Transfer Language, an intermediate representation used by GCC after parsing and before generating machine code. RTL describes operations on registers and memory.
Basic Block
A sequence of instructions with a single entry point and a single exit point. Compilers analyze code in terms of basic blocks for optimization and control flow analysis.
Nonlocal Goto
A control flow transfer that jumps to a label in a different scope or function. In GCC's internal representation, these can complicate basic block analysis if not properly annotated.
Peephole Optimization
A compiler optimization technique that examines a short sequence (a 'peephole') of target machine instructions and replaces it with a shorter or faster equivalent sequence.
Filed Under: optimizationexception handlingcompiler bug