[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.
This commit is contained in:
Kazu Hirata
2024-11-01 19:52:11 -07:00
committed by GitHub
parent 4d3c427f33
commit 890c4bece2
2 changed files with 4 additions and 3 deletions

View File

@@ -69,7 +69,8 @@ AllocationType llvm::memprof::getAllocType(uint64_t TotalLifetimeAccessDensity,
MDNode *llvm::memprof::buildCallstackMetadata(ArrayRef<uint64_t> CallStack,
LLVMContext &Ctx) {
std::vector<Metadata *> StackVals;
SmallVector<Metadata *, 8> StackVals;
StackVals.reserve(CallStack.size());
for (auto Id : CallStack) {
auto *StackValMD =
ValueAsMetadata::get(ConstantInt::get(Type::getInt64Ty(Ctx), Id));

View File

@@ -680,7 +680,7 @@ bool MemProfiler::instrumentFunction(Function &F) {
}
static void addCallsiteMetadata(Instruction &I,
std::vector<uint64_t> &InlinedCallStack,
ArrayRef<uint64_t> 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<uint64_t> InlinedCallStack;
SmallVector<uint64_t, 8> 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