From 0ffa377c6b2583ecb326af8b9084951a106d3881 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 6 Sep 2024 10:25:08 -0700 Subject: [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 RefEdgeList; to: SmallVector 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. --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') 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 &ValueIdToLinkageMap); - std::vector makeRefList(ArrayRef Record); + SmallVector makeRefList(ArrayRef Record); std::vector makeCallList(ArrayRef Record, bool IsOldProfileFormat, bool HasProfile, @@ -7369,9 +7369,9 @@ Error ModuleSummaryIndexBitcodeReader::parseModule() { } } -std::vector +SmallVector ModuleSummaryIndexBitcodeReader::makeRefList(ArrayRef Record) { - std::vector Ret; + SmallVector 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 &Refs, unsigned ROCnt, +static void setSpecialRefs(SmallVectorImpl &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 Refs = makeRefList( + SmallVector Refs = makeRefList( ArrayRef(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 Refs = + SmallVector Refs = makeRefList(ArrayRef(Record).slice(RefArrayStart)); auto FS = std::make_unique(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 Refs = makeRefList( + SmallVector Refs = makeRefList( ArrayRef(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 Refs = makeRefList( + SmallVector Refs = makeRefList( ArrayRef(Record).slice(RefListStartIndex, NumRefs)); bool HasProfile = (BitCode == bitc::FS_COMBINED_PROFILE); std::vector Edges = makeCallList( @@ -7883,7 +7883,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) { GVF = getDecodedGVarFlags(Record[3]); RefArrayStart = 4; } - std::vector Refs = + SmallVector Refs = makeRefList(ArrayRef(Record).slice(RefArrayStart)); auto FS = std::make_unique(Flags, GVF, std::move(Refs)); -- cgit v1.1