[llvm] [ThinLTO] optimize propagateAttributes performance (PR #132917)
Zhaoxuan Jiang via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 27 04:38:21 PDT 2025
nocchijiang wrote:
I managed to grab some interesting profiling data with a RelWithDebInfo `libLTO.dylib`.
# Baseline

Most time are spent in `insert`:

```
19.52 min 68.9% 0 s llvm::detail::DenseSetImpl<llvm::ValueInfo, llvm::DenseMap<llvm::ValueInfo, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::ValueInfo, void>, llvm::detail::DenseSetPair<llvm::ValueInfo>>, llvm::DenseMapInfo<llvm::ValueInfo, void>>::insert(llvm::ValueInfo const&)
1.15 min 4.0% 0 s llvm::detail::DenseSetImpl<llvm::ValueInfo, llvm::DenseMap<llvm::ValueInfo, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::ValueInfo, void>, llvm::detail::DenseSetPair<llvm::ValueInfo>>, llvm::DenseMapInfo<llvm::ValueInfo, void>>::contains(llvm::ValueInfo const&) const
```
# `MarkedNonReadWriteOnly` in `GlobalValueSummaryInfo`

# `MarkedNonReadWriteOnly` in `ValueInfo`


I strongly suspect that the relationship between `ValueInfo` and `GlobalValueSummaryInfo` is not strictly 1-to-1, otherwise the 10x performance difference cannot be explained. This is also the reason why I initially decided to declare the flag in `GlobalValueSummaryInfo`: `DenseMapInfo<ValueInfo>` utilizes the pointer identity of `GlobalValueSummaryMapTy` entry, so the `MarkedNonReadWriteOnly` set was effectively marking the underlying `GlobalValueSummaryInfo` rather than `ValueInfo`. However, I am uncertain whether this is the expected behavior.
https://github.com/llvm/llvm-project/pull/132917
More information about the llvm-commits
mailing list