aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-09-06 10:25:08 -0700
committerGitHub <noreply@github.com>2024-09-06 10:25:08 -0700
commit0ffa377c6b2583ecb326af8b9084951a106d3881 (patch)
tree107b842b4cac1e6dfaae48a6d73a15e1a2a1358f /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parenta291fe5ed44fa37493d038c78ff4d73135fd85a9 (diff)
downloadllvm-0ffa377c6b2583ecb326af8b9084951a106d3881.zip
llvm-0ffa377c6b2583ecb326af8b9084951a106d3881.tar.gz
llvm-0ffa377c6b2583ecb326af8b9084951a106d3881.tar.bz2
[ThinLTO] Shrink GlobalValueSummary by 8 bytes (#107342)
During the ThinLTO indexing step for one of our large applications, we create 7.5 million instances of GlobalValueSummary. Changing: std::vector<ValueInfo> RefEdgeList; to: SmallVector<ValueInfo, 0> RefEdgeList; in GlobalValueSummary reduces the size of each instance by 8 bytes. The rest of the patch makes the same change to other places so that the types stay compatible across function boundaries.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index f887c9b..e52757f 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -985,7 +985,7 @@ private:
Error parseValueSymbolTable(
uint64_t Offset,
DenseMap<unsigned, GlobalValue::LinkageTypes> &ValueIdToLinkageMap);
- std::vector<ValueInfo> makeRefList(ArrayRef<uint64_t> Record);
+ SmallVector<ValueInfo, 0> makeRefList(ArrayRef<uint64_t> Record);
std::vector<FunctionSummary::EdgeTy> makeCallList(ArrayRef<uint64_t> Record,
bool IsOldProfileFormat,
bool HasProfile,
@@ -7369,9 +7369,9 @@ Error ModuleSummaryIndexBitcodeReader::parseModule() {
}
}
-std::vector<ValueInfo>
+SmallVector<ValueInfo, 0>
ModuleSummaryIndexBitcodeReader::makeRefList(ArrayRef<uint64_t> Record) {
- std::vector<ValueInfo> Ret;
+ SmallVector<ValueInfo, 0> Ret;
Ret.reserve(Record.size());
for (uint64_t RefValueId : Record)
Ret.push_back(std::get<0>(getValueInfoFromValueId(RefValueId)));
@@ -7516,7 +7516,7 @@ void ModuleSummaryIndexBitcodeReader::parseTypeIdCompatibleVtableSummaryRecord(
parseTypeIdCompatibleVtableInfo(Record, Slot, TypeId);
}
-static void setSpecialRefs(std::vector<ValueInfo> &Refs, unsigned ROCnt,
+static void setSpecialRefs(SmallVectorImpl<ValueInfo> &Refs, unsigned ROCnt,
unsigned WOCnt) {
// Readonly and writeonly refs are in the end of the refs list.
assert(ROCnt + WOCnt <= Refs.size());
@@ -7666,7 +7666,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
int CallGraphEdgeStartIndex = RefListStartIndex + NumRefs;
assert(Record.size() >= RefListStartIndex + NumRefs &&
"Record size inconsistent with number of references");
- std::vector<ValueInfo> Refs = makeRefList(
+ SmallVector<ValueInfo, 0> Refs = makeRefList(
ArrayRef<uint64_t>(Record).slice(RefListStartIndex, NumRefs));
bool HasProfile = (BitCode == bitc::FS_PERMODULE_PROFILE);
bool HasRelBF = (BitCode == bitc::FS_PERMODULE_RELBF);
@@ -7741,7 +7741,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
GVF = getDecodedGVarFlags(Record[2]);
RefArrayStart = 3;
}
- std::vector<ValueInfo> Refs =
+ SmallVector<ValueInfo, 0> Refs =
makeRefList(ArrayRef<uint64_t>(Record).slice(RefArrayStart));
auto FS =
std::make_unique<GlobalVarSummary>(Flags, GVF, std::move(Refs));
@@ -7762,7 +7762,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
unsigned RefListStartIndex = 4;
unsigned VTableListStartIndex = RefListStartIndex + NumRefs;
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
- std::vector<ValueInfo> Refs = makeRefList(
+ SmallVector<ValueInfo, 0> Refs = makeRefList(
ArrayRef<uint64_t>(Record).slice(RefListStartIndex, NumRefs));
VTableFuncList VTableFuncs;
for (unsigned I = VTableListStartIndex, E = Record.size(); I != E; ++I) {
@@ -7823,7 +7823,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
int CallGraphEdgeStartIndex = RefListStartIndex + NumRefs;
assert(Record.size() >= RefListStartIndex + NumRefs &&
"Record size inconsistent with number of references");
- std::vector<ValueInfo> Refs = makeRefList(
+ SmallVector<ValueInfo, 0> Refs = makeRefList(
ArrayRef<uint64_t>(Record).slice(RefListStartIndex, NumRefs));
bool HasProfile = (BitCode == bitc::FS_COMBINED_PROFILE);
std::vector<FunctionSummary::EdgeTy> Edges = makeCallList(
@@ -7883,7 +7883,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
GVF = getDecodedGVarFlags(Record[3]);
RefArrayStart = 4;
}
- std::vector<ValueInfo> Refs =
+ SmallVector<ValueInfo, 0> Refs =
makeRefList(ArrayRef<uint64_t>(Record).slice(RefArrayStart));
auto FS =
std::make_unique<GlobalVarSummary>(Flags, GVF, std::move(Refs));