diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -25,6 +25,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/MapVector.h" #include "llvm/ADT/PriorityQueue.h" #include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/SmallVector.h" @@ -475,7 +476,7 @@ const SmallVectorImpl &Candidates, const Function &F, bool Hot); void promoteMergeNotInlinedContextSamples( - DenseMap NonInlinedCallSites, + MapVector NonInlinedCallSites, const Function &F); std::vector buildFunctionOrder(Module &M, CallGraph *CG); std::unique_ptr buildProfiledCallGraph(CallGraph &CG); @@ -1106,7 +1107,7 @@ "ProfAccForSymsInList should be false when profile-sample-accurate " "is enabled"); - DenseMap LocalNotInlinedCallSites; + MapVector LocalNotInlinedCallSites; bool Changed = false; bool LocalChanged = true; while (LocalChanged) { @@ -1126,7 +1127,7 @@ AllCandidates.push_back(CB); if (FS->getHeadSamplesEstimate() > 0 || FunctionSamples::ProfileIsCS) - LocalNotInlinedCallSites.try_emplace(CB, FS); + LocalNotInlinedCallSites.insert({CB, FS}); if (callsiteIsHot(FS, PSI, ProfAccForSymsInList)) Hot = true; else if (shouldInlineColdCallee(*CB)) @@ -1409,7 +1410,7 @@ if (ExternalInlineAdvisor) SizeLimit = std::numeric_limits::max(); - DenseMap LocalNotInlinedCallSites; + MapVector LocalNotInlinedCallSites; // Perform iterative BFS call site prioritized inlining bool Changed = false; @@ -1466,7 +1467,7 @@ ICPCount++; Changed = true; } else if (!ContextTracker) { - LocalNotInlinedCallSites.try_emplace(I, FS); + LocalNotInlinedCallSites.insert({I, FS}); } } } else if (CalledFunction && CalledFunction->getSubprogram() && @@ -1479,7 +1480,7 @@ } Changed = true; } else if (!ContextTracker) { - LocalNotInlinedCallSites.try_emplace(I, Candidate.CalleeSamples); + LocalNotInlinedCallSites.insert({I, Candidate.CalleeSamples}); } } else if (LTOPhase == ThinOrFullLTOPhase::ThinLTOPreLink) { findExternalInlineCandidate(I, findCalleeFunctionSamples(*I), @@ -1505,11 +1506,11 @@ } void SampleProfileLoader::promoteMergeNotInlinedContextSamples( - DenseMap NonInlinedCallSites, + MapVector NonInlinedCallSites, const Function &F) { // Accumulate not inlined callsite information into notInlinedSamples for (const auto &Pair : NonInlinedCallSites) { - CallBase *I = Pair.getFirst(); + CallBase *I = Pair.first; Function *Callee = I->getCalledFunction(); if (!Callee || Callee->isDeclaration()) continue; @@ -1521,7 +1522,7 @@ << "' into '" << ore::NV("Caller", &F) << "'"); ++NumCSNotInlined; - const FunctionSamples *FS = Pair.getSecond(); + const FunctionSamples *FS = Pair.second; if (FS->getTotalSamples() == 0 && FS->getHeadSamplesEstimate() == 0) { continue; }