-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[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
[NFC][IR] Wrap std::set into CfiFunctionIndex #130361
Conversation
Created using spr 1.3.4
@llvm/pr-subscribers-llvm-ir Author: Vitaly Buka (vitalybuka) ChangesPreparation for CFI Index refactoring, We need a data structure to lookup by GUID. Full diff: https://github.com/llvm/llvm-project/pull/130361.diff 1 Files Affected:
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 3c586a1dd21d8..ada6bb259dc37 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -1289,6 +1289,30 @@ 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>;
@@ -1418,8 +1442,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).
@@ -1667,19 +1691,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,
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Please fix formatting |
done |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/160/builds/14246 Here is the relevant piece of the build log for the reference
|
Preparation for CFI Index refactoring,
which will fix O(N^2) in ThinLTO indexing.
We need a data structure to lookup by GUID.
Wrapping allow us to change implementation
with minimal changes to users.