Skip to content

Commit 311548f

Browse files
[MemProf] Fix when CallStackTrie is a single chain with multi alloc type
1 parent 480cc41 commit 311548f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

llvm/lib/Analysis/MemoryProfileInfo.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,14 @@ bool CallStackTrie::buildAndAttachMIBMetadata(CallBase *CI) {
244244
MIBCallStack.push_back(AllocStackId);
245245
std::vector<Metadata *> MIBNodes;
246246
assert(!Alloc->Callers.empty() && "addCallStack has not been called yet");
247-
buildMIBNodes(Alloc, Ctx, MIBCallStack, MIBNodes,
248-
/*CalleeHasAmbiguousCallerContext=*/true);
249-
assert(MIBCallStack.size() == 1 &&
250-
"Should only be left with Alloc's location in stack");
251-
CI->setMetadata(LLVMContext::MD_memprof, MDNode::get(Ctx, MIBNodes));
252-
return true;
247+
if (buildMIBNodes(Alloc, Ctx, MIBCallStack, MIBNodes,
248+
Alloc->Callers.size() > 1)) {
249+
assert(MIBCallStack.size() == 1 &&
250+
"Should only be left with Alloc's location in stack");
251+
CI->setMetadata(LLVMContext::MD_memprof, MDNode::get(Ctx, MIBNodes));
252+
return true;
253+
}
254+
return false;
253255
}
254256

255257
template <>

0 commit comments

Comments
 (0)