llvm-project
ca56fd66 - [CIR] Use SymbolUserMap in applyReplacements to fix quadratic behavior (#195883)

Commit
11 days ago
[CIR] Use SymbolUserMap in applyReplacements to fix quadratic behavior (#195883) applyReplacements() previously called replaceAllSymbolUses() for each replacement, which walks the entire module every time — O(R × M) for R replacements and M operations. For C++ programs with heavy template instantiation (e.g., Eigen), this quadratic behavior dominated compile time. Replace the per-replacement module walk with a single SymbolUserMap built once (O(M)), then use replaceAllUsesWith() which scopes each replacement to only the actual user operations. The debug-only verifyPointerTypeArgs helper is also updated to reuse the map. Measured on Eigen's basicstuff.cpp (356 lines, heavy template instantiation): compile time dropped from 20m29s to 1m2s (20x speedup). CIR-to-classic ratio improved from 117x to 7.2x. Made with [Cursor](https://cursor.com) Co-authored-by: Cursor <cursoragent@cursor.com>
Author
Parents
Loading