Skip to content

Commit 890c4be

Browse files
[memprof] Use SmallVector for InlinedCallStack (NFC) (#114599)
We can stay within 8 inlined elements more than 99% of the time while building a large application.
1 parent 4d3c427 commit 890c4be

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

llvm/lib/Analysis/MemoryProfileInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ AllocationType llvm::memprof::getAllocType(uint64_t TotalLifetimeAccessDensity,
6969

7070
MDNode *llvm::memprof::buildCallstackMetadata(ArrayRef<uint64_t> CallStack,
7171
LLVMContext &Ctx) {
72-
std::vector<Metadata *> StackVals;
72+
SmallVector<Metadata *, 8> StackVals;
73+
StackVals.reserve(CallStack.size());
7374
for (auto Id : CallStack) {
7475
auto *StackValMD =
7576
ValueAsMetadata::get(ConstantInt::get(Type::getInt64Ty(Ctx), Id));

llvm/lib/Transforms/Instrumentation/MemProfiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ bool MemProfiler::instrumentFunction(Function &F) {
680680
}
681681

682682
static void addCallsiteMetadata(Instruction &I,
683-
std::vector<uint64_t> &InlinedCallStack,
683+
ArrayRef<uint64_t> InlinedCallStack,
684684
LLVMContext &Ctx) {
685685
I.setMetadata(LLVMContext::MD_callsite,
686686
buildCallstackMetadata(InlinedCallStack, Ctx));
@@ -905,7 +905,7 @@ readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader,
905905
continue;
906906
// List of call stack ids computed from the location hashes on debug
907907
// locations (leaf to inlined at root).
908-
std::vector<uint64_t> InlinedCallStack;
908+
SmallVector<uint64_t, 8> InlinedCallStack;
909909
// Was the leaf location found in one of the profile maps?
910910
bool LeafFound = false;
911911
// If leaf was found in a map, iterators pointing to its location in both

0 commit comments

Comments
 (0)