[llvm] [MemProf] Fix when CallStackTrie is a single chain with multi alloc type (PR #79433)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 06:13:34 PST 2024


================
@@ -244,12 +244,18 @@ bool CallStackTrie::buildAndAttachMIBMetadata(CallBase *CI) {
   MIBCallStack.push_back(AllocStackId);
   std::vector<Metadata *> MIBNodes;
   assert(!Alloc->Callers.empty() && "addCallStack has not been called yet");
-  buildMIBNodes(Alloc, Ctx, MIBCallStack, MIBNodes,
-                /*CalleeHasAmbiguousCallerContext=*/true);
-  assert(MIBCallStack.size() == 1 &&
-         "Should only be left with Alloc's location in stack");
-  CI->setMetadata(LLVMContext::MD_memprof, MDNode::get(Ctx, MIBNodes));
-  return true;
+  if (buildMIBNodes(Alloc, Ctx, MIBCallStack, MIBNodes,
+                    Alloc->Callers.size() > 1)) {
----------------
teresajohnson wrote:

I'm wondering whether this should actually pass in constant false in fact. The parameter is "CalleeHasAmbiguousCallerContext" and meant to say whether the callee of the given node has more than one caller. Here the node being passed in is the alloc and it has no callees. I think if we get to the point where we check this parameter for the alloc that we probably always want it to be false and not create any MIBNode?

https://github.com/llvm/llvm-project/pull/79433


More information about the llvm-commits mailing list