Skip to content

[NFC][IR] Wrap std::set into CfiFunctionIndex #130361

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

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
43 changes: 29 additions & 14 deletions llvm/include/llvm/IR/ModuleSummaryIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,29 @@ struct TypeIdSummary {
std::map<uint64_t, WholeProgramDevirtResolution> WPDRes;
};

class CfiFunctionIndex {
std::set<std::string, std::less<>> Index;

public:
CfiFunctionIndex() = default;

template <typename It> CfiFunctionIndex(It B, It E) : Index(B, E) {}

std::set<std::string, std::less<>>::const_iterator begin() const {
return Index.begin();
}

std::set<std::string, std::less<>>::const_iterator end() const {
return Index.end();
}

template <typename... Args> void emplace(Args &&...A) {
Index.emplace(std::forward<Args>(A)...);
}

size_t count(StringRef S) const { return Index.count(S); }
};

/// 160 bits SHA1
using ModuleHash = std::array<uint32_t, 5>;

Expand Down Expand Up @@ -1418,8 +1441,8 @@ class ModuleSummaryIndex {
/// True if some of the FunctionSummary contains a ParamAccess.
bool HasParamAccess = false;

std::set<std::string, std::less<>> CfiFunctionDefs;
std::set<std::string, std::less<>> CfiFunctionDecls;
CfiFunctionIndex CfiFunctionDefs;
CfiFunctionIndex CfiFunctionDecls;

// Used in cases where we want to record the name of a global, but
// don't have the string owned elsewhere (e.g. the Strtab on a module).
Expand Down Expand Up @@ -1667,19 +1690,11 @@ class ModuleSummaryIndex {
return I == OidGuidMap.end() ? 0 : I->second;
}

std::set<std::string, std::less<>> &cfiFunctionDefs() {
return CfiFunctionDefs;
}
const std::set<std::string, std::less<>> &cfiFunctionDefs() const {
return CfiFunctionDefs;
}
CfiFunctionIndex &cfiFunctionDefs() { return CfiFunctionDefs; }
const CfiFunctionIndex &cfiFunctionDefs() const { return CfiFunctionDefs; }

std::set<std::string, std::less<>> &cfiFunctionDecls() {
return CfiFunctionDecls;
}
const std::set<std::string, std::less<>> &cfiFunctionDecls() const {
return CfiFunctionDecls;
}
CfiFunctionIndex &cfiFunctionDecls() { return CfiFunctionDecls; }
const CfiFunctionIndex &cfiFunctionDecls() const { return CfiFunctionDecls; }

/// Add a global value summary for a value.
void addGlobalValueSummary(const GlobalValue &GV,
Expand Down
Loading