Skip to content

[MemProf] Handle recursion during stack node update #135837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,12 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::
// edge from the prior node.
if (PrevNode) {
auto *PrevEdge = CurNode->findEdgeFromCallee(PrevNode);
assert(PrevEdge);
// If the sequence contained recursion, we might have already removed
// some edges during the connectNewNode calls above.
if (!PrevEdge) {
PrevNode = CurNode;
continue;
}
set_subtract(PrevEdge->getContextIds(), SavedContextIds);
if (PrevEdge->getContextIds().empty())
removeEdgeFromGraph(PrevEdge);
Expand Down
11 changes: 7 additions & 4 deletions llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
;; in the input IR to ensure that the MIB call chain is matched to the longer
;; inline sequences from main.
;;
;; Update: the inlined sequence of callsite ids was manually modified to
;; include some recursion, which reproduced an error before it was fixed.
;;
;; The IR was then reduced using llvm-reduce with the expected FileCheck input.

; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
Expand Down Expand Up @@ -96,13 +99,13 @@ attributes #7 = { builtin }
!6 = !{i32 7, !"frame-pointer", i32 2}
!7 = !{!8, !10}
!8 = !{!9, !"notcold"}
!9 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414}
!9 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -5964873800580613432, i64 8632435727821051414}
!10 = !{!11, !"cold"}
!11 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}
!11 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -5964873800580613432, i64 -3421689549917153178}
!12 = !{i64 9086428284934609951}
!13 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
!14 = !{i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414}
!15 = !{i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}
!14 = !{i64 -5964873800580613432, i64 2732490490862098848, i64 -5964873800580613432, i64 8632435727821051414}
!15 = !{i64 -5964873800580613432, i64 2732490490862098848, i64 -5964873800580613432, i64 -3421689549917153178}


; DUMP: CCG before cloning:
Expand Down
Loading