Skip to content

Commit b2f3ac8

Browse files
[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.
1 parent 4f3a095 commit b2f3ac8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

llvm/lib/Analysis/MemoryProfileInfo.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,9 @@ void CallStackTrie::addCallStack(MDNode *MIB) {
184184
addCallStack(getMIBAllocType(MIB), CallStack, getMIBTotalSize(MIB));
185185
}
186186

187-
static MDNode *createMIBNode(LLVMContext &Ctx,
188-
std::vector<uint64_t> &MIBCallStack,
187+
static MDNode *createMIBNode(LLVMContext &Ctx, ArrayRef<uint64_t> MIBCallStack,
189188
AllocationType AllocType, uint64_t TotalSize) {
190-
std::vector<Metadata *> MIBPayload(
189+
SmallVector<Metadata *> MIBPayload(
191190
{buildCallstackMetadata(MIBCallStack, Ctx)});
192191
MIBPayload.push_back(
193192
MDString::get(Ctx, getAllocTypeAttributeString(AllocType)));

0 commit comments

Comments
 (0)