diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h --- a/llvm/include/llvm/ProfileData/SampleProf.h +++ b/llvm/include/llvm/ProfileData/SampleProf.h @@ -1228,8 +1228,7 @@ raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS); -using SampleProfileMap = - std::unordered_map; +using SampleProfileMap = llvm::DenseMap; using NameFunctionSamples = std::pair; diff --git a/llvm/lib/ProfileData/SampleProf.cpp b/llvm/lib/ProfileData/SampleProf.cpp --- a/llvm/lib/ProfileData/SampleProf.cpp +++ b/llvm/lib/ProfileData/SampleProf.cpp @@ -375,8 +375,8 @@ MergedContext = MergedContext.take_back(ColdContextFrameLength); FunctionSamples NewFunctionSamples; NewFunctionSamples.setContext(MergedContext); - auto Ret = MergedProfileMap.emplace( - SampleContext(MergedContext).getHashCode(), NewFunctionSamples); + auto Ret = MergedProfileMap.insert(std::make_pair( + SampleContext(MergedContext).getHashCode(), NewFunctionSamples)); FunctionSamples &MergedProfile = Ret.first->second; MergedProfile.merge(*I.second); } @@ -391,7 +391,7 @@ continue; // Merge the profile if the original profile exists, otherwise just insert // as a new profile - auto Ret = ProfileMap.emplace(I.first, FunctionSamples()); + auto Ret = ProfileMap.insert(std::make_pair(I.first, FunctionSamples())); FunctionSamples &OrigProfile = Ret.first->second; OrigProfile.merge(I.second); } diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp --- a/llvm/lib/ProfileData/SampleProfReader.cpp +++ b/llvm/lib/ProfileData/SampleProfReader.cpp @@ -877,6 +877,7 @@ if (!LoadFuncsToBeUsed || (UseOrderedFuncOffsets && OrderedFuncOffsets.empty()) || (!UseOrderedFuncOffsets && FuncOffsetTable.empty())) { + while (Data < End) { if (std::error_code EC = readFuncProfile(Data)) return EC; diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp b/llvm/tools/llvm-profgen/ProfileGenerator.cpp --- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp +++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp @@ -474,7 +474,8 @@ FunctionSamples & ProfileGenerator::getTopLevelFunctionProfile(StringRef FuncName) { SampleContext Context(FuncName); - auto Ret = ProfileMap.emplace(Context.getHashCode(), FunctionSamples()); + auto Ret = ProfileMap.insert( + std::make_pair(Context.getHashCode(), FunctionSamples())); if (Ret.second) { FunctionSamples &FProfile = Ret.first->second; FProfile.setContext(Context); @@ -967,8 +968,8 @@ Context.emplace_back(Node.getFuncName(), LineLocation(0, 0)); // Save the new context for future references. SampleContextFrames NewContext = *Contexts.insert(Context).first; - auto Ret = ProfileMap.emplace(SampleContext(NewContext).getHashCode(), - std::move(*FProfile)); + auto Ret = ProfileMap.insert(std::make_pair( + SampleContext(NewContext).getHashCode(), std::move(*FProfile))); FunctionSamples &NewProfile = Ret.first->second; NewProfile.getContext().setContext(NewContext); Context.pop_back();