Skip to content

[MemProf] Add dot graph dumping immediately after stack node update #143025

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 1 commit into from
Jun 5, 2025
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
6 changes: 6 additions & 0 deletions llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2183,6 +2183,9 @@ ModuleCallsiteContextGraph::ModuleCallsiteContextGraph(

updateStackNodes();

if (ExportToDot)
exportToDot("poststackupdate");

handleCallsitesWithMultipleTargets();

markBackedges();
Expand Down Expand Up @@ -2285,6 +2288,9 @@ IndexCallsiteContextGraph::IndexCallsiteContextGraph(

updateStackNodes();

if (ExportToDot)
exportToDot("poststackupdate");

handleCallsitesWithMultipleTargets();

markBackedges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
; RUN: --check-prefix=STATS --check-prefix=REMARKS

; RUN: cat %t.ccg.prestackupdate.dot | FileCheck %s --check-prefix=DOTPRE
;; There are no changes for this test case in between from immediately after
;; the stack update through the end of graph finalization, so the
;; corresponding dot graphs should be identical.
; RUN: cat %t.ccg.poststackupdate.dot | FileCheck %s --check-prefix=DOTPOST
; RUN: cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOTPOST
;; We should clone D once for the cold allocations via C.
; RUN: cat %t.ccg.cloned.dot | FileCheck %s --check-prefix=DOTCLONED
Expand Down Expand Up @@ -313,8 +317,8 @@ attributes #6 = { builtin }
; DOTPRE: }


; DOTPOST:digraph "postbuild" {
; DOTPOST: label="postbuild";
; DOTPOST:digraph "post
; DOTPOST: label="post
; DOTPOST: Node[[D:0x[a-z0-9]+]] [shape=record,tooltip="N[[D]] ContextIds: 1 2 3 4",fillcolor="mediumorchid1",style="filled",label="{OrigId: Alloc0\n_Z1Dv -\> _Znam}"];
; DOTPOST: Node[[F:0x[a-z0-9]+]] [shape=record,tooltip="N[[F]] ContextIds: 2",fillcolor="brown1",style="filled",label="{OrigId: 13543580133643026784\n_Z1Fv -\> _Z1Dv}"];
; DOTPOST: Node[[F]] -> Node[[D]][tooltip="ContextIds: 2",fillcolor="brown1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@
; REQUIRES: asserts

; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
; RUN: -memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
; RUN: -stats -debug %s -S 2>&1 | FileCheck %s --check-prefix=STATS \
; RUN: --check-prefix=IR --check-prefix=DEBUG

; DEBUG: Not found through unique tail call chain: _Z3barv from main that actually called xyz (found multiple possible chains)

;; Graph fixup should have nulled the call in the node that could not be
;; resolved via tail call fixup. That happens in between the initial
;; stack update and the end of graph building.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "and at the end"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is more grammatically correct the way it is? I.e. "between the initial ... and the end"

; RUN: cat %t.ccg.poststackupdate.dot | FileCheck %s --check-prefix=DOTPOSTSTACKUPDATE
; DOTPOSTSTACKUPDATE: {OrigId: 15025054523792398438\nmain -\> xyz}
; RUN: cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOTPOSTBUILD
; DOTPOSTBUILD: {OrigId: 15025054523792398438\nnull call (external)}

;; Check that all calls in the IR are to the original functions, leading to a
;; non-cold operator new call.

Expand Down
Loading