LRA spill candidate trials sped up significantly
Local Register Allocation's spill candidate checking is now much faster, drastically reducing compile times for certain complex functions.
The Local Register Allocation (LRA) pass has been optimized to speed up the process of evaluating spill candidates. By reducing redundant traversals of live ranges and limiting the collection of reload pseudos, compile times for certain complex functions on x86_64 have been reduced from 17.8 seconds to just 0.9 seconds.
In Details
The spill_for function in LRA previously incurred significant overhead by iterating through live ranges of spill candidates multiple times per hard register trial. This patch optimizes spill_for by marking trial spills only in live_pseudos_reg_renumber and having find_hard_regno_for_1 skip pseudos already in live_hard_reg_pseudos if their live_pseudos_reg_renumber is -1. It also prunes the collection of reload pseudos if param_lra_max_considered_reload_pseudos is exceeded. These changes maintain allocation decisions while dramatically improving performance on functions with many…
- LRA
- Local Register Allocation. A compiler optimization pass responsible for assigning program variables to physical machine registers within a function or basic block. It aims to minimize memory accesses by keeping frequently used values in registers.
- Spill Candidate
- A variable or temporary value that the register allocator decides cannot be held in a physical register at a certain point. It must be 'spilled' to memory to free up the register for other uses.
- Live Range
- The portion of a program's execution during which a variable or temporary value holds a meaningful value and might be accessed. The register allocator considers live ranges when deciding where registers can be reused.
- Pseudos
- Virtual registers used by the compiler during register allocation. They represent program variables or temporaries that may or may not be assigned to a physical register.
- Reload Pseudos
- Virtual registers that require a load from memory before use and potentially a store to memory after modification, as they could not be permanently assigned to a physical register.