Skip to content

Commit 0aa5b61

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
1 parent 0db702a commit 0aa5b61

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

llvm/include/llvm/IR/ModuleSummaryIndex.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "llvm/ADT/StringExtras.h"
2424
#include "llvm/ADT/StringMap.h"
2525
#include "llvm/ADT/StringRef.h"
26+
#include "llvm/ADT/iterator_range.h"
2627
#include "llvm/IR/ConstantRange.h"
2728
#include "llvm/IR/GlobalValue.h"
2829
#include "llvm/IR/Module.h"
@@ -1294,6 +1295,25 @@ class CfiFunctionIndex {
12941295

12951296
public:
12961297
CfiFunctionIndex() = default;
1298+
class CfiGUIDIterator
1299+
: public iterator_adaptor_base<
1300+
CfiGUIDIterator, std::set<std::string, std::less<>>::const_iterator,
1301+
std::forward_iterator_tag, GlobalValue::GUID> {
1302+
using base = iterator_adaptor_base<
1303+
CfiGUIDIterator, std::set<std::string, std::less<>>::const_iterator,
1304+
std::forward_iterator_tag, GlobalValue::GUID>;
1305+
1306+
public:
1307+
CfiGUIDIterator() = default;
1308+
explicit CfiGUIDIterator(
1309+
std::set<std::string, std::less<>>::const_iterator I)
1310+
: base(std::move(I)) {}
1311+
1312+
GlobalValue::GUID operator*() const {
1313+
return GlobalValue::getGUID(
1314+
GlobalValue::dropLLVMManglingEscape(*this->wrapped()));
1315+
}
1316+
};
12971317

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

@@ -1305,6 +1325,12 @@ class CfiFunctionIndex {
13051325
return Index.end();
13061326
}
13071327

1328+
CfiGUIDIterator guid_begin() const { return CfiGUIDIterator(Index.begin()); }
1329+
CfiGUIDIterator guid_end() const { return CfiGUIDIterator(Index.end()); }
1330+
iterator_range<CfiGUIDIterator> guids() const {
1331+
return make_range(guid_begin(), guid_end());
1332+
}
1333+
13081334
template <typename... Args> void emplace(Args &&...A) {
13091335
Index.emplace(std::forward<Args>(A)...);
13101336
}

llvm/lib/LTO/LTO.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,12 +1437,10 @@ class InProcessThinBackend : public ThinBackendProc {
14371437
OnWrite, ShouldEmitImportsFiles, ThinLTOParallelism),
14381438
AddStream(std::move(AddStream)), Cache(std::move(Cache)),
14391439
ShouldEmitIndexFiles(ShouldEmitIndexFiles) {
1440-
for (auto &Name : CombinedIndex.cfiFunctionDefs())
1441-
CfiFunctionDefs.insert(
1442-
GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Name)));
1443-
for (auto &Name : CombinedIndex.cfiFunctionDecls())
1444-
CfiFunctionDecls.insert(
1445-
GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Name)));
1440+
auto &Defs = CombinedIndex.cfiFunctionDefs();
1441+
CfiFunctionDefs.insert(Defs.guid_begin(), Defs.guid_end());
1442+
auto &Decls = CombinedIndex.cfiFunctionDecls();
1443+
CfiFunctionDecls.insert(Decls.guid_begin(), Decls.guid_end());
14461444
}
14471445

14481446
virtual Error runThinLTOBackendThread(
@@ -1965,12 +1963,10 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
19651963

19661964
// Any functions referenced by the jump table in the regular LTO object must
19671965
// be exported.
1968-
for (auto &Def : ThinLTO.CombinedIndex.cfiFunctionDefs())
1969-
ExportedGUIDs.insert(
1970-
GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Def)));
1971-
for (auto &Decl : ThinLTO.CombinedIndex.cfiFunctionDecls())
1972-
ExportedGUIDs.insert(
1973-
GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Decl)));
1966+
auto &Defs = ThinLTO.CombinedIndex.cfiFunctionDefs();
1967+
ExportedGUIDs.insert(Defs.guid_begin(), Defs.guid_end());
1968+
auto &Decls = ThinLTO.CombinedIndex.cfiFunctionDecls();
1969+
ExportedGUIDs.insert(Decls.guid_begin(), Decls.guid_end());
19741970

19751971
auto isExported = [&](StringRef ModuleIdentifier, ValueInfo VI) {
19761972
const auto &ExportList = ExportLists.find(ModuleIdentifier);

0 commit comments

Comments
 (0)