diff --git a/llvm/include/llvm/Transforms/IPO/FunctionImport.h b/llvm/include/llvm/Transforms/IPO/FunctionImport.h index 70739709a810a..4b29d3f40ab7b 100644 --- a/llvm/include/llvm/Transforms/IPO/FunctionImport.h +++ b/llvm/include/llvm/Transforms/IPO/FunctionImport.h @@ -270,13 +270,20 @@ class FunctionImporter { // A map from destination modules to lists of imports. class ImportListsTy { public: - ImportListsTy() = default; - ImportListsTy(size_t Size) : ListsImpl(Size) {} + ImportListsTy() : EmptyList(ImportIDs) {} + ImportListsTy(size_t Size) : EmptyList(ImportIDs), ListsImpl(Size) {} ImportMapTy &operator[](StringRef DestMod) { return ListsImpl.try_emplace(DestMod, ImportIDs).first->second; } + const ImportMapTy &lookup(StringRef DestMod) const { + auto It = ListsImpl.find(DestMod); + if (It != ListsImpl.end()) + return It->second; + return EmptyList; + } + size_t size() const { return ListsImpl.size(); } using const_iterator = DenseMap::const_iterator; @@ -284,6 +291,7 @@ class FunctionImporter { const_iterator end() const { return ListsImpl.end(); } private: + ImportMapTy EmptyList; DenseMap ListsImpl; ImportIDTable ImportIDs; };