-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NFC][LTO] Move GUID calculation into CfiFunctionIndex #130370
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][LTO] Move GUID calculation into CfiFunctionIndex #130370
Conversation
Created using spr 1.3.4
|
@llvm/pr-subscribers-lto @llvm/pr-subscribers-llvm-ir Author: Vitaly Buka (vitalybuka) ChangesPreparation for CFI Index refactoring, Full diff: https://github.com/llvm/llvm-project/pull/130370.diff 2 Files Affected:
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 539c130af33fa..53b8135664e7f 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -23,6 +23,7 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Module.h"
@@ -1294,6 +1295,25 @@ class CfiFunctionIndex {
public:
CfiFunctionIndex() = default;
+ class CfiGUIDIterator
+ : public iterator_adaptor_base<
+ CfiGUIDIterator, std::set<std::string, std::less<>>::const_iterator,
+ std::forward_iterator_tag, GlobalValue::GUID> {
+ using base = iterator_adaptor_base<
+ CfiGUIDIterator, std::set<std::string, std::less<>>::const_iterator,
+ std::forward_iterator_tag, GlobalValue::GUID>;
+
+ public:
+ CfiGUIDIterator() = default;
+ explicit CfiGUIDIterator(
+ std::set<std::string, std::less<>>::const_iterator I)
+ : base(std::move(I)) {}
+
+ GlobalValue::GUID operator*() const {
+ return GlobalValue::getGUID(
+ GlobalValue::dropLLVMManglingEscape(*this->wrapped()));
+ }
+ };
template <typename It> CfiFunctionIndex(It B, It E) : Index(B, E) {}
@@ -1305,6 +1325,12 @@ class CfiFunctionIndex {
return Index.end();
}
+ CfiGUIDIterator guid_begin() const { return CfiGUIDIterator(Index.begin()); }
+ CfiGUIDIterator guid_end() const { return CfiGUIDIterator(Index.end()); }
+ iterator_range<CfiGUIDIterator> guids() const {
+ return make_range(guid_begin(), guid_end());
+ }
+
template <typename... Args> void emplace(Args &&...A) {
Index.emplace(std::forward<Args>(A)...);
}
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index dfd4b5188907d..e895a46b8cd77 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -1437,12 +1437,10 @@ class InProcessThinBackend : public ThinBackendProc {
OnWrite, ShouldEmitImportsFiles, ThinLTOParallelism),
AddStream(std::move(AddStream)), Cache(std::move(Cache)),
ShouldEmitIndexFiles(ShouldEmitIndexFiles) {
- for (auto &Name : CombinedIndex.cfiFunctionDefs())
- CfiFunctionDefs.insert(
- GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Name)));
- for (auto &Name : CombinedIndex.cfiFunctionDecls())
- CfiFunctionDecls.insert(
- GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Name)));
+ auto &Defs = CombinedIndex.cfiFunctionDefs();
+ CfiFunctionDefs.insert(Defs.guid_begin(), Defs.guid_end());
+ auto &Decls = CombinedIndex.cfiFunctionDecls();
+ CfiFunctionDecls.insert(Decls.guid_begin(), Decls.guid_end());
}
virtual Error runThinLTOBackendThread(
@@ -1965,12 +1963,10 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
// Any functions referenced by the jump table in the regular LTO object must
// be exported.
- for (auto &Def : ThinLTO.CombinedIndex.cfiFunctionDefs())
- ExportedGUIDs.insert(
- GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Def)));
- for (auto &Decl : ThinLTO.CombinedIndex.cfiFunctionDecls())
- ExportedGUIDs.insert(
- GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Decl)));
+ auto &Defs = ThinLTO.CombinedIndex.cfiFunctionDefs();
+ ExportedGUIDs.insert(Defs.guid_begin(), Defs.guid_end());
+ auto &Decls = ThinLTO.CombinedIndex.cfiFunctionDecls();
+ ExportedGUIDs.insert(Decls.guid_begin(), Decls.guid_end());
auto isExported = [&](StringRef ModuleIdentifier, ValueInfo VI) {
const auto &ExportList = ExportLists.find(ModuleIdentifier);
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/871 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/46/builds/13210 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/54/builds/7113 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/2/builds/18762 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.