[llvm] [IR] Reduce memory usage in metadata use tracking (NFC) (PR #221866)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 13 18:13:15 PDT 2026


MaskRay wrote:

I agree with the core premise: `SmallDenseMap<...> UseMap` in ReplaceableUses isn't ideal, and SmallVector is a much better fit. My hesitation is the complexity of the large mode implementation.

Based on some benchmarking I ran recently (`-O3 -g -fdebug-info-for-profiling -flto=thin`, pinned to P-cores, 5 rounds):


```
    main          1455800 KB   26.52 s
    this PR       1354784 KB   26.25 s
    plain vector  1333064 KB   26.31 s
```

The plain vector approach gets us very similar wins without needing `IsLarge, NumDead, tombstones, compact<>()`, or a context-global `MetadataUseMap`. The obvious downside to the plain vector is the $O(n)$ hazard in dropRef/moveRef. While it didn't show up as a bottleneck in my tests, I agree it's a bad hazard to leave exposed.

https://github.com/llvm/llvm-project/pull/221866


More information about the llvm-commits mailing list