sched-deps: Release reg_last lists outside of reg_last_in_use
Fixes memory leaks in sched-deps by ensuring lists are returned to the recycler.
This commit addresses a memory leak in the sched-deps component where certain lists associated with register usage were not being properly released. Specifically, debug-insn and control-use paths added lists to reg_last that were not tracked by reg_last_in_use, preventing them from being returned to the recycler. A new reg_last_dirty set is introduced to track these lists, and they are now merged into reg_last_in_use during teardown to ensure proper deallocation. A selftest is added to verify this fix.
In Details
The sched-deps component tracks dependencies between instructions to aid in scheduling. Specifically, reg_last_in_use tracks which reg_last entries are currently in use. However, certain paths, like debug-insn and control-use analysis, add INSN_LIST nodes to reg_last without updating reg_last_in_use. These nodes were then leaked. This patch introduces reg_last_dirty to capture these lists temporarily and merges them into reg_last_in_use before freeing, ensuring all lists are returned to the recycler. This prevents potential memory leaks and ensures correct dependency analysis,…
- sched-deps
- A component within the GCC compiler that analyzes and manages dependencies between instructions to optimize instruction scheduling.
- reg_last
- A data structure within
sched-depsthat likely stores information about the last usage of registers. - reg_last_in_use
- A subset of
reg_lastthat tracks which entries are currently actively in use, helping to manage register lifetimes and dependencies. - INSN_LIST
- A data structure representing a list of instructions, used in
sched-depsfor tracking grouped instruction dependencies. - recycler
- A memory management mechanism that reclaims and reuses objects (like
INSN_LISTnodes) instead of deallocating them, improving performance.