Skip to content
Merged
Show file tree
Hide file tree
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
27 changes: 26 additions & 1 deletion llvm/include/llvm/IR/ModuleSummaryIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -1293,8 +1294,26 @@ class CfiFunctionIndex {
std::set<std::string, std::less<>> Index;

public:
CfiFunctionIndex() = default;
class GUIDIterator
: public iterator_adaptor_base<
GUIDIterator, std::set<std::string, std::less<>>::const_iterator,
std::forward_iterator_tag, GlobalValue::GUID> {
using base = iterator_adaptor_base<
GUIDIterator, std::set<std::string, std::less<>>::const_iterator,
std::forward_iterator_tag, GlobalValue::GUID>;

public:
GUIDIterator() = default;
explicit GUIDIterator(std::set<std::string, std::less<>>::const_iterator I)
: base(std::move(I)) {}

GlobalValue::GUID operator*() const {
return GlobalValue::getGUID(
GlobalValue::dropLLVMManglingEscape(*this->wrapped()));
}
};

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

std::set<std::string, std::less<>>::const_iterator begin() const {
Expand All @@ -1305,6 +1324,12 @@ class CfiFunctionIndex {
return Index.end();
}

GUIDIterator guid_begin() const { return GUIDIterator(Index.begin()); }
GUIDIterator guid_end() const { return GUIDIterator(Index.end()); }
iterator_range<GUIDIterator> guids() const {
return make_range(guid_begin(), guid_end());
}

template <typename... Args> void emplace(Args &&...A) {
Index.emplace(std::forward<Args>(A)...);
}
Expand Down
20 changes: 8 additions & 12 deletions llvm/lib/LTO/LTO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down
Loading