From: Teresa Johnson Date: Wed, 19 Oct 2022 18:39:10 +0000 (-0700) Subject: [BitcodeReader] Convert pair to triple in preparation for MemProf (NFC) X-Git-Tag: upstream/17.0.6~30083 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=646e25d05146d2f0d517364cf78a6fa68d77bf71;p=platform%2Fupstream%2Fllvm.git [BitcodeReader] Convert pair to triple in preparation for MemProf (NFC) Extracted from D135714 which adds summary support for MemProf. We will need a 3rd tuple member in the ValueIdToValueInfoMap, this patch makes a number of NFC changes to the existing clients of that map to reflect the conversion of pair to tuple. --- diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index bfce79c..cfbc5fa 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -885,7 +885,7 @@ class ModuleSummaryIndexBitcodeReader : public BitcodeReaderBase { // We save a GUID which refers to the same global as the ValueInfo, but // ignoring the linkage, i.e. for values other than local linkage they are // identical. - DenseMap> + DenseMap> ValueIdToValueInfoMap; /// Map populated during module path string table parsing, from the @@ -932,7 +932,7 @@ private: std::vector parseParamAccesses(ArrayRef Record); - std::pair + std::tuple getValueInfoFromValueId(unsigned ValueId); void addThisModule(); @@ -6606,10 +6606,10 @@ ModuleSummaryIndexBitcodeReader::getThisModule() { return TheIndex.getModule(ModulePath); } -std::pair +std::tuple ModuleSummaryIndexBitcodeReader::getValueInfoFromValueId(unsigned ValueId) { auto VGI = ValueIdToValueInfoMap[ValueId]; - assert(VGI.first); + assert(std::get<0>(VGI)); return VGI; } @@ -6629,10 +6629,9 @@ void ModuleSummaryIndexBitcodeReader::setValueGUID( // UseStrtab is false for legacy summary formats and value names are // created on stack. In that case we save the name in a string saver in // the index so that the value name can be recorded. - ValueIdToValueInfoMap[ValueID] = std::make_pair( + ValueIdToValueInfoMap[ValueID] = std::make_tuple( TheIndex.getOrInsertValueInfo( - ValueGUID, - UseStrtab ? ValueName : TheIndex.saveString(ValueName)), + ValueGUID, UseStrtab ? ValueName : TheIndex.saveString(ValueName)), OriginalNameID); } @@ -6722,7 +6721,7 @@ Error ModuleSummaryIndexBitcodeReader::parseValueSymbolTable( // The "original name", which is the second value of the pair will be // overriden later by a FS_COMBINED_ORIGINAL_NAME in the combined index. ValueIdToValueInfoMap[ValueID] = - std::make_pair(TheIndex.getOrInsertValueInfo(RefGUID), RefGUID); + std::make_tuple(TheIndex.getOrInsertValueInfo(RefGUID), RefGUID); break; } } @@ -6876,7 +6875,7 @@ ModuleSummaryIndexBitcodeReader::makeRefList(ArrayRef Record) { std::vector Ret; Ret.reserve(Record.size()); for (uint64_t RefValueId : Record) - Ret.push_back(getValueInfoFromValueId(RefValueId).first); + Ret.push_back(std::get<0>(getValueInfoFromValueId(RefValueId))); return Ret; } @@ -6889,7 +6888,7 @@ ModuleSummaryIndexBitcodeReader::makeCallList(ArrayRef Record, for (unsigned I = 0, E = Record.size(); I != E; ++I) { CalleeInfo::HotnessType Hotness = CalleeInfo::HotnessType::Unknown; uint64_t RelBF = 0; - ValueInfo Callee = getValueInfoFromValueId(Record[I]).first; + ValueInfo Callee = std::get<0>(getValueInfoFromValueId(Record[I])); if (IsOldProfileFormat) { I += 1; // Skip old callsitecount field if (HasProfile) @@ -6980,7 +6979,7 @@ ModuleSummaryIndexBitcodeReader::parseParamAccesses(ArrayRef Record) { for (auto &Call : ParamAccess.Calls) { Call.ParamNo = Record.front(); Record = Record.drop_front(); - Call.Callee = getValueInfoFromValueId(Record.front()).first; + Call.Callee = std::get<0>(getValueInfoFromValueId(Record.front())); Record = Record.drop_front(); Call.Offsets = ReadRange(); } @@ -6992,7 +6991,7 @@ void ModuleSummaryIndexBitcodeReader::parseTypeIdCompatibleVtableInfo( ArrayRef Record, size_t &Slot, TypeIdCompatibleVtableInfo &TypeId) { uint64_t Offset = Record[Slot++]; - ValueInfo Callee = getValueInfoFromValueId(Record[Slot++]).first; + ValueInfo Callee = std::get<0>(getValueInfoFromValueId(Record[Slot++])); TypeId.push_back({Offset, Callee}); } @@ -7106,7 +7105,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) { uint64_t ValueID = Record[0]; GlobalValue::GUID RefGUID = Record[1]; ValueIdToValueInfoMap[ValueID] = - std::make_pair(TheIndex.getOrInsertValueInfo(RefGUID), RefGUID); + std::make_tuple(TheIndex.getOrInsertValueInfo(RefGUID), RefGUID); break; } // FS_PERMODULE: [valueid, flags, instcount, fflags, numrefs, @@ -7168,8 +7167,9 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) { std::move(PendingParamAccesses)); auto VIAndOriginalGUID = getValueInfoFromValueId(ValueID); FS->setModulePath(getThisModule()->first()); - FS->setOriginalName(VIAndOriginalGUID.second); - TheIndex.addGlobalValueSummary(VIAndOriginalGUID.first, std::move(FS)); + FS->setOriginalName(std::get<1>(VIAndOriginalGUID)); + TheIndex.addGlobalValueSummary(std::get<0>(VIAndOriginalGUID), + std::move(FS)); break; } // FS_ALIAS: [valueid, flags, valueid] @@ -7188,15 +7188,15 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) { // ownership. AS->setModulePath(getThisModule()->first()); - auto AliaseeVI = getValueInfoFromValueId(AliaseeID).first; + auto AliaseeVI = std::get<0>(getValueInfoFromValueId(AliaseeID)); auto AliaseeInModule = TheIndex.findSummaryInModule(AliaseeVI, ModulePath); if (!AliaseeInModule) return error("Alias expects aliasee summary to be parsed"); AS->setAliasee(AliaseeVI, AliaseeInModule); auto GUID = getValueInfoFromValueId(ValueID); - AS->setOriginalName(GUID.second); - TheIndex.addGlobalValueSummary(GUID.first, std::move(AS)); + AS->setOriginalName(std::get<1>(GUID)); + TheIndex.addGlobalValueSummary(std::get<0>(GUID), std::move(AS)); break; } // FS_PERMODULE_GLOBALVAR_INIT_REFS: [valueid, flags, varflags, n x valueid] @@ -7219,8 +7219,8 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) { std::make_unique(Flags, GVF, std::move(Refs)); FS->setModulePath(getThisModule()->first()); auto GUID = getValueInfoFromValueId(ValueID); - FS->setOriginalName(GUID.second); - TheIndex.addGlobalValueSummary(GUID.first, std::move(FS)); + FS->setOriginalName(std::get<1>(GUID)); + TheIndex.addGlobalValueSummary(std::get<0>(GUID), std::move(FS)); break; } // FS_PERMODULE_VTABLE_GLOBALVAR_INIT_REFS: [valueid, flags, varflags, @@ -7238,7 +7238,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) { ArrayRef(Record).slice(RefListStartIndex, NumRefs)); VTableFuncList VTableFuncs; for (unsigned I = VTableListStartIndex, E = Record.size(); I != E; ++I) { - ValueInfo Callee = getValueInfoFromValueId(Record[I]).first; + ValueInfo Callee = std::get<0>(getValueInfoFromValueId(Record[I])); uint64_t Offset = Record[++I]; VTableFuncs.push_back({Callee, Offset}); } @@ -7247,8 +7247,8 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) { VS->setModulePath(getThisModule()->first()); VS->setVTableFuncs(VTableFuncs); auto GUID = getValueInfoFromValueId(ValueID); - VS->setOriginalName(GUID.second); - TheIndex.addGlobalValueSummary(GUID.first, std::move(VS)); + VS->setOriginalName(std::get<1>(GUID)); + TheIndex.addGlobalValueSummary(std::get<0>(GUID), std::move(VS)); break; } // FS_COMBINED: [valueid, modid, flags, instcount, fflags, numrefs, @@ -7299,7 +7299,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) { std::vector Edges = makeCallList( ArrayRef(Record).slice(CallGraphEdgeStartIndex), IsOldProfileFormat, HasProfile, false); - ValueInfo VI = getValueInfoFromValueId(ValueID).first; + ValueInfo VI = std::get<0>(getValueInfoFromValueId(ValueID)); setSpecialRefs(Refs, NumRORefs, NumWORefs); auto FS = std::make_unique( Flags, InstCount, getDecodedFFlags(RawFunFlags), EntryCount, @@ -7328,11 +7328,11 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) { LastSeenSummary = AS.get(); AS->setModulePath(ModuleIdMap[ModuleId]); - auto AliaseeVI = getValueInfoFromValueId(AliaseeValueId).first; + auto AliaseeVI = std::get<0>(getValueInfoFromValueId(AliaseeValueId)); auto AliaseeInModule = TheIndex.findSummaryInModule(AliaseeVI, AS->modulePath()); AS->setAliasee(AliaseeVI, AliaseeInModule); - ValueInfo VI = getValueInfoFromValueId(ValueID).first; + ValueInfo VI = std::get<0>(getValueInfoFromValueId(ValueID)); LastSeenGUID = VI.getGUID(); TheIndex.addGlobalValueSummary(VI, std::move(AS)); break; @@ -7358,7 +7358,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) { std::make_unique(Flags, GVF, std::move(Refs)); LastSeenSummary = FS.get(); FS->setModulePath(ModuleIdMap[ModuleId]); - ValueInfo VI = getValueInfoFromValueId(ValueID).first; + ValueInfo VI = std::get<0>(getValueInfoFromValueId(ValueID)); LastSeenGUID = VI.getGUID(); TheIndex.addGlobalValueSummary(VI, std::move(FS)); break;