Backthreader reuses path analysis objects for efficiency.
Compiler pass reuses analysis objects to significantly speed up code analysis.
The backthreader pass has been optimized by reusing a single path_range_query object across multiple candidate paths. This eliminates redundant allocations and setup for path analysis, leading to a substantial performance improvement in the thread_blocks function and overall compilation time.
In Details
The backthreader::find_taken_edge_* functions previously constructed a new path_range_query object for each candidate path. This commit modifies the backthreader to allocate a single path_range_query instance (m_solver) and reuse it via its reset_path method. This significantly reduces overhead from repeated path_oracle allocation, ssa_lazy_cache setup, and heap vector allocations, resulting in a 6.7% performance improvement for back_threader::thread_blocks() and a 0.08% improvement for the entire compile time over the tested corpus.
- backthreader
- A compiler pass in GCC that analyzes and optimizes code flow, potentially related to backward analysis or threading through control flow graphs.
- path_range_query
- An internal GCC data structure used for analyzing the properties of paths within a control flow graph, likely involving range analysis of variables.
- candidate path
- A potential sequence of basic blocks or control flow edges being considered by an optimization algorithm.
- ssa_lazy_cache
- A cache mechanism used in conjunction with Static Single Assignment (SSA) form, likely for optimizing lookups or computations related to SSA values.
- control flow graph (CFG)
- A representation of all execution paths in a program, used by compilers for analysis and optimization.
- Static Single Assignment (SSA)
- An intermediate representation property where each variable is assigned exactly once, simplifying many compiler optimizations.