aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-09-07 11:21:20 -0700
committerGitHub <noreply@github.com>2024-09-07 11:21:20 -0700
commit51d3829d8fc5beba269629903365af75174de7f6 (patch)
tree6124ee8620c87d5d5a4d11a48c26bd3bd069a5b9 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parenta1e06f767440010f605b82d97950433f687e4b45 (diff)
downloadllvm-51d3829d8fc5beba269629903365af75174de7f6.zip
llvm-51d3829d8fc5beba269629903365af75174de7f6.tar.gz
llvm-51d3829d8fc5beba269629903365af75174de7f6.tar.bz2
[ThinLTO] Shrink FunctionSummary by 8 bytes (#107706)
During the ThinLTO indexing step for one of our large applications, we create 4 million instances of FunctionSummary. Changing: std::vector<EdgeTy> CallGraphEdgeList; to: SmallVector<EdgeTy, 0> CallGraphEdgeList; in FunctionSummary 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.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 4d00b64..4faee1f 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -986,10 +986,9 @@ private:
uint64_t Offset,
DenseMap<unsigned, GlobalValue::LinkageTypes> &ValueIdToLinkageMap);
SmallVector<ValueInfo, 0> makeRefList(ArrayRef<uint64_t> Record);
- std::vector<FunctionSummary::EdgeTy> makeCallList(ArrayRef<uint64_t> Record,
- bool IsOldProfileFormat,
- bool HasProfile,
- bool HasRelBF);
+ SmallVector<FunctionSummary::EdgeTy, 0>
+ makeCallList(ArrayRef<uint64_t> Record, bool IsOldProfileFormat,
+ bool HasProfile, bool HasRelBF);
Error parseEntireSummary(unsigned ID);
Error parseModuleStringTable();
void parseTypeIdCompatibleVtableSummaryRecord(ArrayRef<uint64_t> Record);
@@ -7378,11 +7377,11 @@ ModuleSummaryIndexBitcodeReader::makeRefList(ArrayRef<uint64_t> Record) {
return Ret;
}
-std::vector<FunctionSummary::EdgeTy>
+SmallVector<FunctionSummary::EdgeTy, 0>
ModuleSummaryIndexBitcodeReader::makeCallList(ArrayRef<uint64_t> Record,
bool IsOldProfileFormat,
bool HasProfile, bool HasRelBF) {
- std::vector<FunctionSummary::EdgeTy> Ret;
+ SmallVector<FunctionSummary::EdgeTy, 0> Ret;
// In the case of new profile formats, there are two Record entries per
// Edge. Otherwise, conservatively reserve up to Record.size.
if (!IsOldProfileFormat && (HasProfile || HasRelBF))
@@ -7670,7 +7669,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
ArrayRef<uint64_t>(Record).slice(RefListStartIndex, NumRefs));
bool HasProfile = (BitCode == bitc::FS_PERMODULE_PROFILE);
bool HasRelBF = (BitCode == bitc::FS_PERMODULE_RELBF);
- std::vector<FunctionSummary::EdgeTy> Calls = makeCallList(
+ SmallVector<FunctionSummary::EdgeTy, 0> Calls = makeCallList(
ArrayRef<uint64_t>(Record).slice(CallGraphEdgeStartIndex),
IsOldProfileFormat, HasProfile, HasRelBF);
setSpecialRefs(Refs, NumRORefs, NumWORefs);
@@ -7824,7 +7823,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
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(
+ SmallVector<FunctionSummary::EdgeTy, 0> Edges = makeCallList(
ArrayRef<uint64_t>(Record).slice(CallGraphEdgeStartIndex),
IsOldProfileFormat, HasProfile, false);
ValueInfo VI = std::get<0>(getValueInfoFromValueId(ValueID));