Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ThinLTO] Add lookup to ImportListsTy #109036

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions llvm/include/llvm/Transforms/IPO/FunctionImport.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,28 @@ 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<StringRef, ImportMapTy>::const_iterator;
const_iterator begin() const { return ListsImpl.begin(); }
const_iterator end() const { return ListsImpl.end(); }

private:
ImportMapTy EmptyList;
DenseMap<StringRef, ImportMapTy> ListsImpl;
ImportIDTable ImportIDs;
};
Expand Down
Loading