diff --git a/llvm/lib/Analysis/MemoryProfileInfo.cpp b/llvm/lib/Analysis/MemoryProfileInfo.cpp index 2b49dce17b79..d3d125893377 100644 --- a/llvm/lib/Analysis/MemoryProfileInfo.cpp +++ b/llvm/lib/Analysis/MemoryProfileInfo.cpp @@ -69,7 +69,8 @@ AllocationType llvm::memprof::getAllocType(uint64_t TotalLifetimeAccessDensity, MDNode *llvm::memprof::buildCallstackMetadata(ArrayRef CallStack, LLVMContext &Ctx) { - std::vector StackVals; + SmallVector StackVals; + StackVals.reserve(CallStack.size()); for (auto Id : CallStack) { auto *StackValMD = ValueAsMetadata::get(ConstantInt::get(Type::getInt64Ty(Ctx), Id)); diff --git a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp index 4a43120c9a9e..248d72ea2cca 100644 --- a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp @@ -680,7 +680,7 @@ bool MemProfiler::instrumentFunction(Function &F) { } static void addCallsiteMetadata(Instruction &I, - std::vector &InlinedCallStack, + ArrayRef InlinedCallStack, LLVMContext &Ctx) { I.setMetadata(LLVMContext::MD_callsite, buildCallstackMetadata(InlinedCallStack, Ctx)); @@ -905,7 +905,7 @@ readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader, continue; // List of call stack ids computed from the location hashes on debug // locations (leaf to inlined at root). - std::vector InlinedCallStack; + SmallVector InlinedCallStack; // Was the leaf location found in one of the profile maps? bool LeafFound = false; // If leaf was found in a map, iterators pointing to its location in both