[llvm] [MemProf] Fix assert when exists direct recursion (PR #78264)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 13:13:20 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:
I ran into an assert in the operator* method because ContextIterBegin was already at StackContext.end() (after skipping the shared prefix above). I think this should be:
```
uint64_t LastStackContextId = (ContextIter != StackContext.end() && *ContextIterBegin == 0) ? 1 : 0;
```
Can you send a fix?
https://github.com/llvm/llvm-project/pull/78264
More information about the llvm-commits
mailing list