GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
cfghooks

cfghooks: Move IR Type Inside cfghooks Structure

The IR type is now part of the `cfg_hooks` structure, which helps with future constification efforts.

This commit moves the IR type (ir_type) inside the cfg_hooks structure. Previously, the IR type was determined by comparing variables, which complicated later changes. Moving the IR type into the cfg_hooks structure simplifies the code and paves the way for making the structure const, especially in scenarios where sel-sched overloads hooks.

In Details

This change is a step toward constifying cfg_hooks. By moving the ir_type field into struct cfg_hooks, the compiler no longer needs to compare variables to determine the current IR type. This is relevant to sel-sched-ir.cc, which overloads some hooks. Affected files include cfghooks.cc, cfgrtl.cc, and tree-cfg.cc.

For Context

The intermediate representation (IR) is a representation of source code used during compilation. The cfg_hooks structure provides customization points for how the compiler builds and manipulates the control flow graph (CFG) for different IRs. This commit moves the IR type directly into the cfg_hooks structure, which simplifies the code and sets the stage for future improvements like making the structure constant, which can prevent accidental modification.

Filed Under: cfgrefactorir