Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 26 additions & 0 deletions 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 @@ -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) {}

Expand All @@ -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)...);
}
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