[llvm] b2f3ac8 - [memprof] Teach createMIBNode to take ArrayRef (NFC) (#111195)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 4 13:56:45 PDT 2024
Author: Kazu Hirata
Date: 2024-10-04T13:56:42-07:00
New Revision: b2f3ac836aac166b8fb21690a0a480c816de0521
URL: https://github.com/llvm/llvm-project/commit/b2f3ac836aac166b8fb21690a0a480c816de0521
DIFF: https://github.com/llvm/llvm-project/commit/b2f3ac836aac166b8fb21690a0a480c816de0521.diff
LOG: [memprof] Teach createMIBNode to take ArrayRef (NFC) (#111195)
createMIBNode does not modify MIBCallStack, so we can take ArrayRef
instead.
While I am at it, this patch changes the type of MIBPayload to
SmallVector. We put at most three elements, so we can avoid a heap
allocation.
Added:
Modified:
llvm/lib/Analysis/MemoryProfileInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/MemoryProfileInfo.cpp b/llvm/lib/Analysis/MemoryProfileInfo.cpp
index 3a752d42241a95..2b49dce17b7931 100644
--- a/llvm/lib/Analysis/MemoryProfileInfo.cpp
+++ b/llvm/lib/Analysis/MemoryProfileInfo.cpp
@@ -184,10 +184,9 @@ void CallStackTrie::addCallStack(MDNode *MIB) {
addCallStack(getMIBAllocType(MIB), CallStack, getMIBTotalSize(MIB));
}
-static MDNode *createMIBNode(LLVMContext &Ctx,
- std::vector<uint64_t> &MIBCallStack,
+static MDNode *createMIBNode(LLVMContext &Ctx, ArrayRef<uint64_t> MIBCallStack,
AllocationType AllocType, uint64_t TotalSize) {
- std::vector<Metadata *> MIBPayload(
+ SmallVector<Metadata *> MIBPayload(
{buildCallstackMetadata(MIBCallStack, Ctx)});
MIBPayload.push_back(
MDString::get(Ctx, getAllocTypeAttributeString(AllocType)));
More information about the llvm-commits
mailing list