GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc

Add prevailing exit edge to copy_bbs.

Control flow graph copier improved to handle abnormal exit edges.

The basic block (BB) copier in GCC’s control flow graph (CFG) handling has been enhanced to recognize a ‘prevailing exit edge’. This allows the backwards threader to correctly manage abnormal edges (like exceptions or early returns) that leave a copied region. The changes modify cfghooks.h and cfghooks.cc to incorporate this new concept, ensuring that such abnormal exits are handled properly without misinterpreting the control flow. New test cases verify this functionality.

In Details

The copy_bbs function, part of GCC's CFG manipulation utilities, is responsible for copying basic blocks. This commit introduces the concept of a 'prevailing exit edge' to copy_bbs and can_copy_bbs_p. This is crucial for the ssa-threadupdate pass, which uses copy_bbs when dealing with control flow paths that have abnormal successors. By identifying and preserving a specific 'prevailing' exit edge, the compiler can correctly thread through these abnormal control flow transfers, preventing misinterpretations of the CFG, especially when the copied region ends in an abnormal edge.

For Context
basic block (BB)
A contiguous sequence of zero or more imperative statements in which the execution enters at the top and proceeds through the bottom without any branches in or out, except possibly at the beginning or end.
Control Flow Graph (CFG)
A representation of all the execution paths through a function or program. It is a directed graph where nodes represent basic blocks and edges represent the possible transfers of control between blocks.
backwards threader
A component within GCC's compiler passes that analyzes and updates control flow information, often propagating information backward through the CFG. It is used here to handle the threading of control flow after basic blocks are copied.
prevailing exit edge
A specific edge leaving a basic block or region that is considered the primary or 'normal' exit, even if other abnormal exits exist. This commit teaches the BB copier to identify and respect such an edge.
Filed Under: optimizationcontrol flow graphrefactor