backward threader: Scope path solver lifecycle
Optimizes backward threader by creating and destroying the path solver only when needed for a search.
This commit improves the efficiency of GCC’s backward threader by adjusting the lifecycle of the path solver. Previously, the path solver was created when the threader was initialized and persisted until destruction, even if not actively used. Now, it’s created at the beginning of a search and destroyed at its end. This change, along with making the solver creation a virtual method, prepares for future enhancements without altering current functionality.
In Details
The back_threader class in tree-ssa-threadbackward.cc/.h previously held a path solver instance for its entire lifetime. This commit modifies it to create the solver on-demand within the search method and destroy it afterward. This is achieved by introducing a virtual make_solver method. This change optimizes resource usage by ensuring the path solver is only active during active searches, and it paves the way for subclassing back_threader to provide custom path solvers.
- backward threader
- A GCC analysis pass that traverses the control flow graph in reverse to gather information, often used for data-flow analysis.
- path solver
- A component within GCC that analyzes control flow and data dependencies to determine properties like variable ranges or possible execution paths.
- virtual method
- A method in a base class that can be redefined in a derived class to provide a specialized implementation.