forked from OSchip/llvm-project
Create a typedef GlobalValue::GUID for uint64_t and RAUW (NFC)
Summary: This should make the code more readable, especially all the map declarations. Reviewers: tejohnson Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D18721 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265215
This commit is contained in:
parent
2cd609482d
commit
ad5741b075
|
@ -320,13 +320,18 @@ public:
|
||||||
/// used as the key for a global lookup (e.g. profile or ThinLTO).
|
/// used as the key for a global lookup (e.g. profile or ThinLTO).
|
||||||
std::string getGlobalIdentifier();
|
std::string getGlobalIdentifier();
|
||||||
|
|
||||||
/// Return a 64-bit global unique ID constructed from global value name
|
/// Declare a type to represent a global unique identifier for a global value.
|
||||||
/// (i.e. returned by getGlobalIdentifier()).
|
/// This is a 64 bits hash that is used by PGO and ThinLTO to have a compact
|
||||||
static uint64_t getGUID(StringRef GlobalName) { return MD5Hash(GlobalName); }
|
/// unique way to identify a symbol.
|
||||||
|
using GUID = uint64_t;
|
||||||
|
|
||||||
/// Return a 64-bit global unique ID constructed from global value name
|
/// Return a 64-bit global unique ID constructed from global value name
|
||||||
/// (i.e. returned by getGlobalIdentifier()).
|
/// (i.e. returned by getGlobalIdentifier()).
|
||||||
uint64_t getGUID() { return getGUID(getGlobalIdentifier()); }
|
static GUID getGUID(StringRef GlobalName) { return MD5Hash(GlobalName); }
|
||||||
|
|
||||||
|
/// Return a 64-bit global unique ID constructed from global value name
|
||||||
|
/// (i.e. returned by getGlobalIdentifier()).
|
||||||
|
GUID getGUID() { return getGUID(getGlobalIdentifier()); }
|
||||||
|
|
||||||
/// @name Materialization
|
/// @name Materialization
|
||||||
/// Materialization is used to construct functions only as they're needed.
|
/// Materialization is used to construct functions only as they're needed.
|
||||||
|
|
|
@ -82,7 +82,7 @@ private:
|
||||||
/// (either by the initializer of a global variable, or referenced
|
/// (either by the initializer of a global variable, or referenced
|
||||||
/// from within a function). This does not include functions called, which
|
/// from within a function). This does not include functions called, which
|
||||||
/// are listed in the derived FunctionSummary object.
|
/// are listed in the derived FunctionSummary object.
|
||||||
std::vector<uint64_t> RefEdgeList;
|
std::vector<GlobalValue::GUID> RefEdgeList;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// GlobalValueSummary constructor.
|
/// GlobalValueSummary constructor.
|
||||||
|
@ -107,7 +107,7 @@ public:
|
||||||
|
|
||||||
/// Record a reference from this global value to the global value identified
|
/// Record a reference from this global value to the global value identified
|
||||||
/// by \p RefGUID.
|
/// by \p RefGUID.
|
||||||
void addRefEdge(uint64_t RefGUID) { RefEdgeList.push_back(RefGUID); }
|
void addRefEdge(GlobalValue::GUID RefGUID) { RefEdgeList.push_back(RefGUID); }
|
||||||
|
|
||||||
/// Record a reference from this global value to each global value identified
|
/// Record a reference from this global value to each global value identified
|
||||||
/// in \p RefEdges.
|
/// in \p RefEdges.
|
||||||
|
@ -117,8 +117,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the list of GUIDs referenced by this global value definition.
|
/// Return the list of GUIDs referenced by this global value definition.
|
||||||
std::vector<uint64_t> &refs() { return RefEdgeList; }
|
std::vector<GlobalValue::GUID> &refs() { return RefEdgeList; }
|
||||||
const std::vector<uint64_t> &refs() const { return RefEdgeList; }
|
const std::vector<GlobalValue::GUID> &refs() const { return RefEdgeList; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Function summary information to aid decisions and implementation of
|
/// \brief Function summary information to aid decisions and implementation of
|
||||||
|
@ -126,7 +126,7 @@ public:
|
||||||
class FunctionSummary : public GlobalValueSummary {
|
class FunctionSummary : public GlobalValueSummary {
|
||||||
public:
|
public:
|
||||||
/// <CalleeGUID, CalleeInfo> call edge pair.
|
/// <CalleeGUID, CalleeInfo> call edge pair.
|
||||||
typedef std::pair<uint64_t, CalleeInfo> EdgeTy;
|
typedef std::pair<GlobalValue::GUID, CalleeInfo> EdgeTy;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Number of instructions (ignoring debug instructions, e.g.) computed
|
/// Number of instructions (ignoring debug instructions, e.g.) computed
|
||||||
|
@ -152,7 +152,7 @@ public:
|
||||||
/// Record a call graph edge from this function to the function identified
|
/// Record a call graph edge from this function to the function identified
|
||||||
/// by \p CalleeGUID, with \p CalleeInfo including the cumulative profile
|
/// by \p CalleeGUID, with \p CalleeInfo including the cumulative profile
|
||||||
/// count (across all calls from this function) or 0 if no PGO.
|
/// count (across all calls from this function) or 0 if no PGO.
|
||||||
void addCallGraphEdge(uint64_t CalleeGUID, CalleeInfo Info) {
|
void addCallGraphEdge(GlobalValue::GUID CalleeGUID, CalleeInfo Info) {
|
||||||
CallGraphEdgeList.push_back(std::make_pair(CalleeGUID, Info));
|
CallGraphEdgeList.push_back(std::make_pair(CalleeGUID, Info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ typedef std::vector<std::unique_ptr<GlobalValueInfo>> GlobalValueInfoList;
|
||||||
/// less overhead, as the value type is not very small and the size
|
/// less overhead, as the value type is not very small and the size
|
||||||
/// of the map is unknown, resulting in inefficiencies due to repeated
|
/// of the map is unknown, resulting in inefficiencies due to repeated
|
||||||
/// insertions and resizing.
|
/// insertions and resizing.
|
||||||
typedef std::map<uint64_t, GlobalValueInfoList> GlobalValueInfoMapTy;
|
typedef std::map<GlobalValue::GUID, GlobalValueInfoList> GlobalValueInfoMapTy;
|
||||||
|
|
||||||
/// Type used for iterating through the global value info map.
|
/// Type used for iterating through the global value info map.
|
||||||
typedef GlobalValueInfoMapTy::const_iterator const_globalvalueinfo_iterator;
|
typedef GlobalValueInfoMapTy::const_iterator const_globalvalueinfo_iterator;
|
||||||
|
@ -293,7 +293,7 @@ public:
|
||||||
|
|
||||||
/// Get the list of global value info objects for a given value GUID.
|
/// Get the list of global value info objects for a given value GUID.
|
||||||
const const_globalvalueinfo_iterator
|
const const_globalvalueinfo_iterator
|
||||||
findGlobalValueInfoList(uint64_t ValueGUID) const {
|
findGlobalValueInfoList(GlobalValue::GUID ValueGUID) const {
|
||||||
return GlobalValueMap.find(ValueGUID);
|
return GlobalValueMap.find(ValueGUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a global value info for a value of the given GUID.
|
/// Add a global value info for a value of the given GUID.
|
||||||
void addGlobalValueInfo(uint64_t ValueGUID,
|
void addGlobalValueInfo(GlobalValue::GUID ValueGUID,
|
||||||
std::unique_ptr<GlobalValueInfo> Info) {
|
std::unique_ptr<GlobalValueInfo> Info) {
|
||||||
GlobalValueMap[ValueGUID].push_back(std::move(Info));
|
GlobalValueMap[ValueGUID].push_back(std::move(Info));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#define LLVM_FUNCTIONIMPORT_H
|
#define LLVM_FUNCTIONIMPORT_H
|
||||||
|
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
|
#include "llvm/IR/GlobalValue.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -29,7 +30,7 @@ public:
|
||||||
/// containing all the functions to import for a source module.
|
/// containing all the functions to import for a source module.
|
||||||
/// The keys is the GUID identifying a function to import, and the value
|
/// The keys is the GUID identifying a function to import, and the value
|
||||||
/// is the threshold applied when deciding to import it.
|
/// is the threshold applied when deciding to import it.
|
||||||
typedef std::map<uint64_t, unsigned> FunctionsToImportTy;
|
typedef std::map<GlobalValue::GUID, unsigned> FunctionsToImportTy;
|
||||||
|
|
||||||
/// The map contains an entry for every module to import from, the key being
|
/// The map contains an entry for every module to import from, the key being
|
||||||
/// the module identifier to pass to the ModuleLoader. The value is the set of
|
/// the module identifier to pass to the ModuleLoader. The value is the set of
|
||||||
|
@ -37,7 +38,7 @@ public:
|
||||||
typedef StringMap<FunctionsToImportTy> ImportMapTy;
|
typedef StringMap<FunctionsToImportTy> ImportMapTy;
|
||||||
|
|
||||||
/// The set contains an entry for every global value the module exports.
|
/// The set contains an entry for every global value the module exports.
|
||||||
typedef std::unordered_set<uint64_t> ExportSetTy;
|
typedef std::unordered_set<GlobalValue::GUID> ExportSetTy;
|
||||||
|
|
||||||
/// Create a Function Importer.
|
/// Create a Function Importer.
|
||||||
FunctionImporter(
|
FunctionImporter(
|
||||||
|
|
|
@ -446,7 +446,7 @@ class ModuleSummaryIndexBitcodeReader {
|
||||||
// call graph edges read from the function summary from referencing
|
// call graph edges read from the function summary from referencing
|
||||||
// callees by their ValueId to using the GUID instead, which is how
|
// callees by their ValueId to using the GUID instead, which is how
|
||||||
// they are recorded in the summary index being built.
|
// they are recorded in the summary index being built.
|
||||||
DenseMap<unsigned, uint64_t> ValueIdToCallGraphGUIDMap;
|
DenseMap<unsigned, GlobalValue::GUID> ValueIdToCallGraphGUIDMap;
|
||||||
|
|
||||||
/// Map to save the association between summary offset in the VST to the
|
/// Map to save the association between summary offset in the VST to the
|
||||||
/// GlobalValueInfo object created when parsing it. Used to access the
|
/// GlobalValueInfo object created when parsing it. Used to access the
|
||||||
|
@ -502,7 +502,7 @@ private:
|
||||||
std::error_code initStream(std::unique_ptr<DataStreamer> Streamer);
|
std::error_code initStream(std::unique_ptr<DataStreamer> Streamer);
|
||||||
std::error_code initStreamFromBuffer();
|
std::error_code initStreamFromBuffer();
|
||||||
std::error_code initLazyStream(std::unique_ptr<DataStreamer> Streamer);
|
std::error_code initLazyStream(std::unique_ptr<DataStreamer> Streamer);
|
||||||
uint64_t getGUIDFromValueId(unsigned ValueId);
|
GlobalValue::GUID getGUIDFromValueId(unsigned ValueId);
|
||||||
GlobalValueInfo *getInfoFromSummaryOffset(uint64_t Offset);
|
GlobalValueInfo *getInfoFromSummaryOffset(uint64_t Offset);
|
||||||
};
|
};
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
@ -5444,7 +5444,8 @@ void ModuleSummaryIndexBitcodeReader::freeState() { Buffer = nullptr; }
|
||||||
|
|
||||||
void ModuleSummaryIndexBitcodeReader::releaseBuffer() { Buffer.release(); }
|
void ModuleSummaryIndexBitcodeReader::releaseBuffer() { Buffer.release(); }
|
||||||
|
|
||||||
uint64_t ModuleSummaryIndexBitcodeReader::getGUIDFromValueId(unsigned ValueId) {
|
GlobalValue::GUID
|
||||||
|
ModuleSummaryIndexBitcodeReader::getGUIDFromValueId(unsigned ValueId) {
|
||||||
auto VGI = ValueIdToCallGraphGUIDMap.find(ValueId);
|
auto VGI = ValueIdToCallGraphGUIDMap.find(ValueId);
|
||||||
assert(VGI != ValueIdToCallGraphGUIDMap.end());
|
assert(VGI != ValueIdToCallGraphGUIDMap.end());
|
||||||
return VGI->second;
|
return VGI->second;
|
||||||
|
@ -5540,7 +5541,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseValueSymbolTable(
|
||||||
// VST_CODE_COMBINED_GVDEFENTRY: [valueid, offset, guid]
|
// VST_CODE_COMBINED_GVDEFENTRY: [valueid, offset, guid]
|
||||||
unsigned ValueID = Record[0];
|
unsigned ValueID = Record[0];
|
||||||
uint64_t GlobalValSummaryOffset = Record[1];
|
uint64_t GlobalValSummaryOffset = Record[1];
|
||||||
uint64_t GlobalValGUID = Record[2];
|
GlobalValue::GUID GlobalValGUID = Record[2];
|
||||||
std::unique_ptr<GlobalValueInfo> GlobalValInfo =
|
std::unique_ptr<GlobalValueInfo> GlobalValInfo =
|
||||||
llvm::make_unique<GlobalValueInfo>(GlobalValSummaryOffset);
|
llvm::make_unique<GlobalValueInfo>(GlobalValSummaryOffset);
|
||||||
SummaryOffsetToInfoMap[GlobalValSummaryOffset] = GlobalValInfo.get();
|
SummaryOffsetToInfoMap[GlobalValSummaryOffset] = GlobalValInfo.get();
|
||||||
|
@ -5551,7 +5552,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseValueSymbolTable(
|
||||||
case bitc::VST_CODE_COMBINED_ENTRY: {
|
case bitc::VST_CODE_COMBINED_ENTRY: {
|
||||||
// VST_CODE_COMBINED_ENTRY: [valueid, refguid]
|
// VST_CODE_COMBINED_ENTRY: [valueid, refguid]
|
||||||
unsigned ValueID = Record[0];
|
unsigned ValueID = Record[0];
|
||||||
uint64_t RefGUID = Record[1];
|
GlobalValue::GUID RefGUID = Record[1];
|
||||||
ValueIdToCallGraphGUIDMap[ValueID] = RefGUID;
|
ValueIdToCallGraphGUIDMap[ValueID] = RefGUID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5787,7 +5788,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||||
"Record size inconsistent with number of references");
|
"Record size inconsistent with number of references");
|
||||||
for (unsigned I = 4, E = CallGraphEdgeStartIndex; I != E; ++I) {
|
for (unsigned I = 4, E = CallGraphEdgeStartIndex; I != E; ++I) {
|
||||||
unsigned RefValueId = Record[I];
|
unsigned RefValueId = Record[I];
|
||||||
uint64_t RefGUID = getGUIDFromValueId(RefValueId);
|
GlobalValue::GUID RefGUID = getGUIDFromValueId(RefValueId);
|
||||||
FS->addRefEdge(RefGUID);
|
FS->addRefEdge(RefGUID);
|
||||||
}
|
}
|
||||||
bool HasProfile = (BitCode == bitc::FS_PERMODULE_PROFILE);
|
bool HasProfile = (BitCode == bitc::FS_PERMODULE_PROFILE);
|
||||||
|
@ -5796,11 +5797,11 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||||
unsigned CalleeValueId = Record[I];
|
unsigned CalleeValueId = Record[I];
|
||||||
unsigned CallsiteCount = Record[++I];
|
unsigned CallsiteCount = Record[++I];
|
||||||
uint64_t ProfileCount = HasProfile ? Record[++I] : 0;
|
uint64_t ProfileCount = HasProfile ? Record[++I] : 0;
|
||||||
uint64_t CalleeGUID = getGUIDFromValueId(CalleeValueId);
|
GlobalValue::GUID CalleeGUID = getGUIDFromValueId(CalleeValueId);
|
||||||
FS->addCallGraphEdge(CalleeGUID,
|
FS->addCallGraphEdge(CalleeGUID,
|
||||||
CalleeInfo(CallsiteCount, ProfileCount));
|
CalleeInfo(CallsiteCount, ProfileCount));
|
||||||
}
|
}
|
||||||
uint64_t GUID = getGUIDFromValueId(ValueID);
|
GlobalValue::GUID GUID = getGUIDFromValueId(ValueID);
|
||||||
auto InfoList = TheIndex->findGlobalValueInfoList(GUID);
|
auto InfoList = TheIndex->findGlobalValueInfoList(GUID);
|
||||||
assert(InfoList != TheIndex->end() &&
|
assert(InfoList != TheIndex->end() &&
|
||||||
"Expected VST parse to create GlobalValueInfo entry");
|
"Expected VST parse to create GlobalValueInfo entry");
|
||||||
|
@ -5821,10 +5822,10 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||||
TheIndex->addModulePath(Buffer->getBufferIdentifier(), 0)->first());
|
TheIndex->addModulePath(Buffer->getBufferIdentifier(), 0)->first());
|
||||||
for (unsigned I = 2, E = Record.size(); I != E; ++I) {
|
for (unsigned I = 2, E = Record.size(); I != E; ++I) {
|
||||||
unsigned RefValueId = Record[I];
|
unsigned RefValueId = Record[I];
|
||||||
uint64_t RefGUID = getGUIDFromValueId(RefValueId);
|
GlobalValue::GUID RefGUID = getGUIDFromValueId(RefValueId);
|
||||||
FS->addRefEdge(RefGUID);
|
FS->addRefEdge(RefGUID);
|
||||||
}
|
}
|
||||||
uint64_t GUID = getGUIDFromValueId(ValueID);
|
GlobalValue::GUID GUID = getGUIDFromValueId(ValueID);
|
||||||
auto InfoList = TheIndex->findGlobalValueInfoList(GUID);
|
auto InfoList = TheIndex->findGlobalValueInfoList(GUID);
|
||||||
assert(InfoList != TheIndex->end() &&
|
assert(InfoList != TheIndex->end() &&
|
||||||
"Expected VST parse to create GlobalValueInfo entry");
|
"Expected VST parse to create GlobalValueInfo entry");
|
||||||
|
@ -5855,7 +5856,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||||
"Record size inconsistent with number of references");
|
"Record size inconsistent with number of references");
|
||||||
for (unsigned I = 4, E = CallGraphEdgeStartIndex; I != E; ++I) {
|
for (unsigned I = 4, E = CallGraphEdgeStartIndex; I != E; ++I) {
|
||||||
unsigned RefValueId = Record[I];
|
unsigned RefValueId = Record[I];
|
||||||
uint64_t RefGUID = getGUIDFromValueId(RefValueId);
|
GlobalValue::GUID RefGUID = getGUIDFromValueId(RefValueId);
|
||||||
FS->addRefEdge(RefGUID);
|
FS->addRefEdge(RefGUID);
|
||||||
}
|
}
|
||||||
bool HasProfile = (BitCode == bitc::FS_COMBINED_PROFILE);
|
bool HasProfile = (BitCode == bitc::FS_COMBINED_PROFILE);
|
||||||
|
@ -5864,7 +5865,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||||
unsigned CalleeValueId = Record[I];
|
unsigned CalleeValueId = Record[I];
|
||||||
unsigned CallsiteCount = Record[++I];
|
unsigned CallsiteCount = Record[++I];
|
||||||
uint64_t ProfileCount = HasProfile ? Record[++I] : 0;
|
uint64_t ProfileCount = HasProfile ? Record[++I] : 0;
|
||||||
uint64_t CalleeGUID = getGUIDFromValueId(CalleeValueId);
|
GlobalValue::GUID CalleeGUID = getGUIDFromValueId(CalleeValueId);
|
||||||
FS->addCallGraphEdge(CalleeGUID,
|
FS->addCallGraphEdge(CalleeGUID,
|
||||||
CalleeInfo(CallsiteCount, ProfileCount));
|
CalleeInfo(CallsiteCount, ProfileCount));
|
||||||
}
|
}
|
||||||
|
@ -5883,7 +5884,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||||
FS->setModulePath(ModuleIdMap[ModuleId]);
|
FS->setModulePath(ModuleIdMap[ModuleId]);
|
||||||
for (unsigned I = 2, E = Record.size(); I != E; ++I) {
|
for (unsigned I = 2, E = Record.size(); I != E; ++I) {
|
||||||
unsigned RefValueId = Record[I];
|
unsigned RefValueId = Record[I];
|
||||||
uint64_t RefGUID = getGUIDFromValueId(RefValueId);
|
GlobalValue::GUID RefGUID = getGUIDFromValueId(RefValueId);
|
||||||
FS->addRefEdge(RefGUID);
|
FS->addRefEdge(RefGUID);
|
||||||
}
|
}
|
||||||
auto *Info = getInfoFromSummaryOffset(CurRecordBit);
|
auto *Info = getInfoFromSummaryOffset(CurRecordBit);
|
||||||
|
|
|
@ -2397,10 +2397,9 @@ static void WriteValueSymbolTable(
|
||||||
|
|
||||||
/// Emit function names and summary offsets for the combined index
|
/// Emit function names and summary offsets for the combined index
|
||||||
/// used by ThinLTO.
|
/// used by ThinLTO.
|
||||||
static void
|
static void WriteCombinedValueSymbolTable(
|
||||||
WriteCombinedValueSymbolTable(const ModuleSummaryIndex &Index,
|
const ModuleSummaryIndex &Index, BitstreamWriter &Stream,
|
||||||
BitstreamWriter &Stream,
|
std::map<GlobalValue::GUID, unsigned> &GUIDToValueIdMap,
|
||||||
std::map<uint64_t, unsigned> &GUIDToValueIdMap,
|
|
||||||
uint64_t VSTOffsetPlaceholder) {
|
uint64_t VSTOffsetPlaceholder) {
|
||||||
assert(VSTOffsetPlaceholder > 0 && "Expected non-zero VSTOffsetPlaceholder");
|
assert(VSTOffsetPlaceholder > 0 && "Expected non-zero VSTOffsetPlaceholder");
|
||||||
// Get the offset of the VST we are writing, and backpatch it into
|
// Get the offset of the VST we are writing, and backpatch it into
|
||||||
|
@ -2427,7 +2426,7 @@ WriteCombinedValueSymbolTable(const ModuleSummaryIndex &Index,
|
||||||
SmallVector<uint64_t, 64> NameVals;
|
SmallVector<uint64_t, 64> NameVals;
|
||||||
|
|
||||||
for (const auto &FII : Index) {
|
for (const auto &FII : Index) {
|
||||||
uint64_t FuncGUID = FII.first;
|
GlobalValue::GUID FuncGUID = FII.first;
|
||||||
const auto &VMI = GUIDToValueIdMap.find(FuncGUID);
|
const auto &VMI = GUIDToValueIdMap.find(FuncGUID);
|
||||||
assert(VMI != GUIDToValueIdMap.end());
|
assert(VMI != GUIDToValueIdMap.end());
|
||||||
|
|
||||||
|
@ -3052,7 +3051,8 @@ static void WritePerModuleGlobalValueSummary(
|
||||||
/// Emit the combined summary section into the combined index file.
|
/// Emit the combined summary section into the combined index file.
|
||||||
static void WriteCombinedGlobalValueSummary(
|
static void WriteCombinedGlobalValueSummary(
|
||||||
const ModuleSummaryIndex &I, BitstreamWriter &Stream,
|
const ModuleSummaryIndex &I, BitstreamWriter &Stream,
|
||||||
std::map<uint64_t, unsigned> &GUIDToValueIdMap, unsigned GlobalValueId) {
|
std::map<GlobalValue::GUID, unsigned> &GUIDToValueIdMap,
|
||||||
|
unsigned GlobalValueId) {
|
||||||
Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
|
Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
|
||||||
|
|
||||||
// Abbrev for FS_COMBINED.
|
// Abbrev for FS_COMBINED.
|
||||||
|
@ -3445,7 +3445,7 @@ void llvm::WriteIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out) {
|
||||||
// in writing out the call graph edges. Save the mapping from GUID
|
// in writing out the call graph edges. Save the mapping from GUID
|
||||||
// to the new global value id to use when writing those edges, which
|
// to the new global value id to use when writing those edges, which
|
||||||
// are currently saved in the index in terms of GUID.
|
// are currently saved in the index in terms of GUID.
|
||||||
std::map<uint64_t, unsigned> GUIDToValueIdMap;
|
std::map<GlobalValue::GUID, unsigned> GUIDToValueIdMap;
|
||||||
unsigned GlobalValueId = 0;
|
unsigned GlobalValueId = 0;
|
||||||
for (auto &II : Index)
|
for (auto &II : Index)
|
||||||
GUIDToValueIdMap[II.first] = ++GlobalValueId;
|
GUIDToValueIdMap[II.first] = ++GlobalValueId;
|
||||||
|
|
|
@ -23,7 +23,7 @@ void ModuleSummaryIndex::mergeFrom(std::unique_ptr<ModuleSummaryIndex> Other,
|
||||||
|
|
||||||
StringRef ModPath;
|
StringRef ModPath;
|
||||||
for (auto &OtherGlobalValInfoLists : *Other) {
|
for (auto &OtherGlobalValInfoLists : *Other) {
|
||||||
uint64_t ValueGUID = OtherGlobalValInfoLists.first;
|
GlobalValue::GUID ValueGUID = OtherGlobalValInfoLists.first;
|
||||||
GlobalValueInfoList &List = OtherGlobalValInfoLists.second;
|
GlobalValueInfoList &List = OtherGlobalValInfoLists.second;
|
||||||
|
|
||||||
// Assert that the value info list only has one entry, since we shouldn't
|
// Assert that the value info list only has one entry, since we shouldn't
|
||||||
|
|
|
@ -103,7 +103,8 @@ selectCallee(const GlobalValueInfoList &CalleeInfoList, unsigned Threshold) {
|
||||||
|
|
||||||
/// Return the summary for the function \p GUID that fits the \p Threshold, or
|
/// Return the summary for the function \p GUID that fits the \p Threshold, or
|
||||||
/// null if there's no match.
|
/// null if there's no match.
|
||||||
static const FunctionSummary *selectCallee(uint64_t GUID, unsigned Threshold,
|
static const FunctionSummary *selectCallee(GlobalValue::GUID GUID,
|
||||||
|
unsigned Threshold,
|
||||||
const ModuleSummaryIndex &Index) {
|
const ModuleSummaryIndex &Index) {
|
||||||
auto CalleeInfoList = Index.findGlobalValueInfoList(GUID);
|
auto CalleeInfoList = Index.findGlobalValueInfoList(GUID);
|
||||||
if (CalleeInfoList == Index.end()) {
|
if (CalleeInfoList == Index.end()) {
|
||||||
|
@ -114,7 +115,8 @@ static const FunctionSummary *selectCallee(uint64_t GUID, unsigned Threshold,
|
||||||
|
|
||||||
/// Return true if the global \p GUID is exported by module \p ExportModulePath.
|
/// Return true if the global \p GUID is exported by module \p ExportModulePath.
|
||||||
static bool isGlobalExported(const ModuleSummaryIndex &Index,
|
static bool isGlobalExported(const ModuleSummaryIndex &Index,
|
||||||
StringRef ExportModulePath, uint64_t GUID) {
|
StringRef ExportModulePath,
|
||||||
|
GlobalValue::GUID GUID) {
|
||||||
auto CalleeInfoList = Index.findGlobalValueInfoList(GUID);
|
auto CalleeInfoList = Index.findGlobalValueInfoList(GUID);
|
||||||
if (CalleeInfoList == Index.end())
|
if (CalleeInfoList == Index.end())
|
||||||
// This global does not have a summary, it is not part of the ThinLTO
|
// This global does not have a summary, it is not part of the ThinLTO
|
||||||
|
@ -138,7 +140,7 @@ using EdgeInfo = std::pair<const FunctionSummary *, unsigned /* Threshold */>;
|
||||||
static void computeImportForFunction(
|
static void computeImportForFunction(
|
||||||
StringRef ModulePath, const FunctionSummary &Summary,
|
StringRef ModulePath, const FunctionSummary &Summary,
|
||||||
const ModuleSummaryIndex &Index, unsigned Threshold,
|
const ModuleSummaryIndex &Index, unsigned Threshold,
|
||||||
const std::map<uint64_t, FunctionSummary *> &DefinedFunctions,
|
const std::map<GlobalValue::GUID, FunctionSummary *> &DefinedFunctions,
|
||||||
SmallVectorImpl<EdgeInfo> &Worklist,
|
SmallVectorImpl<EdgeInfo> &Worklist,
|
||||||
FunctionImporter::ImportMapTy &ImportsForModule,
|
FunctionImporter::ImportMapTy &ImportsForModule,
|
||||||
StringMap<FunctionImporter::ExportSetTy> &ExportLists) {
|
StringMap<FunctionImporter::ExportSetTy> &ExportLists) {
|
||||||
|
@ -198,7 +200,7 @@ static void computeImportForFunction(
|
||||||
/// another module (that may require promotion).
|
/// another module (that may require promotion).
|
||||||
static void ComputeImportForModule(
|
static void ComputeImportForModule(
|
||||||
StringRef ModulePath,
|
StringRef ModulePath,
|
||||||
const std::map<uint64_t, FunctionSummary *> &DefinedFunctions,
|
const std::map<GlobalValue::GUID, FunctionSummary *> &DefinedFunctions,
|
||||||
const ModuleSummaryIndex &Index,
|
const ModuleSummaryIndex &Index,
|
||||||
FunctionImporter::ImportMapTy &ImportsForModule,
|
FunctionImporter::ImportMapTy &ImportsForModule,
|
||||||
StringMap<FunctionImporter::ExportSetTy> &ExportLists) {
|
StringMap<FunctionImporter::ExportSetTy> &ExportLists) {
|
||||||
|
@ -242,8 +244,8 @@ void llvm::ComputeCrossModuleImport(
|
||||||
|
|
||||||
// Collect for each module the list of function it defines.
|
// Collect for each module the list of function it defines.
|
||||||
// GUID -> Summary
|
// GUID -> Summary
|
||||||
StringMap<std::map<uint64_t, FunctionSummary *>> Module2FunctionInfoMap(
|
StringMap<std::map<GlobalValue::GUID, FunctionSummary *>>
|
||||||
ModuleCount);
|
Module2FunctionInfoMap(ModuleCount);
|
||||||
|
|
||||||
for (auto &GlobalList : Index) {
|
for (auto &GlobalList : Index) {
|
||||||
auto GUID = GlobalList.first;
|
auto GUID = GlobalList.first;
|
||||||
|
|
Loading…
Reference in New Issue