[all-commits] [llvm/llvm-project] ca56fd: [CIR] Use SymbolUserMap in applyReplacements to fi...

adams381 via All-commits all-commits at lists.llvm.org
Tue May 5 15:45:58 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ca56fd667e0dd9b5d705163d32317477d6328f4b
      https://github.com/llvm/llvm-project/commit/ca56fd667e0dd9b5d705163d32317477d6328f4b
  Author: adams381 <adams at nvidia.com>
  Date:   2026-05-05 (Tue, 05 May 2026)

  Changed paths:
    M clang/lib/CIR/CodeGen/CIRGenModule.cpp

  Log Message:
  -----------
  [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 at cursor.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list