Backward threader separates search from application
Refactors backward threader to split search logic from thread application for cleaner future integration.
The backward threader pass in GCC has been refactored to separate the search for threads from the actual application of those threads. This change is a preparatory step for integrating the FRE (Function Reordering for Execution) pass, making the code cleaner and more modular for subsequent development.
This improves the maintainability and extensibility of the compiler’s optimization passes, particularly in the area of control flow analysis and optimization.
In Details
The tree-ssa-threadbackward.cc file now distinguishes between searching for backward threads and applying them. The back_threader class gained new search() and apply() methods, with thread_blocks() orchestrating their use. This is motivated by upcoming work to integrate the FRE pass, necessitating a cleaner separation of concerns within the existing backward threading logic. The destructor was also made virtual to support potential subclassing.
- backward threader
- A compiler optimization pass that identifies and analyzes control flow paths that go backward, often in loops or complex control structures. It helps in understanding and optimizing program execution flow.
- FRE pass
- Function Reordering for Execution pass, a compiler optimization that aims to improve instruction cache performance by reordering functions in memory to group frequently called or related functions together.
- SSA
- Static Single Assignment form, an intermediate representation in compilers where every variable is assigned exactly once. It simplifies many optimizations by making data flow explicit.