[llvm] [MemProf] Fix assert when exists direct recursion (PR #78264)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 7 08:01:16 PST 2024


================
@@ -3470,17 +3470,19 @@ bool MemProfContextDisambiguation::applyImport(Module &M) {
             auto *MIBMD = cast<const MDNode>(MDOp);
             MDNode *StackMDNode = getMIBStackNode(MIBMD);
             assert(StackMDNode);
-            SmallVector<unsigned> StackIdsFromMetadata;
             CallStack<MDNode, MDNode::op_iterator> StackContext(StackMDNode);
-            for (auto ContextIter =
-                     StackContext.beginAfterSharedPrefix(CallsiteContext);
+            auto ContextIterBegin =
+                StackContext.beginAfterSharedPrefix(CallsiteContext);
+            // Skip the checking on the first iteration.
+            uint64_t LastStackContextId = *ContextIterBegin == 0 ? 1 : 0;
----------------
teresajohnson wrote:

The allocs list on the FS is different than the list of context ids on a given MIB though, so not sure how that assert is related?

The assert you propose will fire in the case that I saw, this is the reason we are getting the assert in operator*. Since this is breaking our memprof builds I have a fix and a testcase that I will send for review shortly. I'm not exactly sure why we are seeing this case, I assume it happened during inlining but in that case we should have ended up replacing the memprof metadata with an attribute. I have a FIXME in the test to investigate this. But at this point I want to unblock our builds.

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


More information about the llvm-commits mailing list