[llvm] [IR] Reduce memory usage in metadata use tracking (NFC) (PR #221866)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 00:19:08 PDT 2026
================
@@ -1636,6 +1636,11 @@ class LLVMContextImpl {
DenseMap<Value *, ValueAsMetadata *> ValuesAsMetadata;
DenseMap<Metadata *, MetadataAsValue *> MetadataAsValues;
DenseSet<DIArgList *, DIArgListInfo> DIArgLists;
+ // Maps a tracked metadata reference pointer (void *Ref) to its current index
+ // in ReplaceableMetadataImpl::UseMap. Only populated for replaceable metadata
+ // instances in Large Mode (IsLarge == true). Instantiated eagerly in the
+ // constructor and reset to std::nullopt at teardown.
+ std::optional<DenseMap<void *, unsigned>> MetadataUseMap;
----------------
aengelke wrote:
I'm a bit worried that this map will never shrink.
Also, std::optional seems pointless here, just use an empty map for the start and clear the map in the destructor if that helps?
https://github.com/llvm/llvm-project/pull/221866
More information about the llvm-commits
mailing list