[llvm] [MemProf] Include caller clone information in dot graph nodes (PR #150492)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 24 21:19:23 PDT 2025
https://github.com/teresajohnson updated https://github.com/llvm/llvm-project/pull/150492
>From a43e3097d9c8dce07e71bcd06b361ddbfad192ce Mon Sep 17 00:00:00 2001
From: Teresa Johnson <tejohnson at google.com>
Date: Thu, 24 Jul 2025 11:22:48 -0700
Subject: [PATCH 1/3] [MemProf] Include caller clone information in dot graph
nodes
We already included the assigned clone of the callsite node's callee in
the dot graph after function assignment. This adds the same information
for the enclosing caller function to aid debugging.
---
.../Transforms/IPO/MemProfContextDisambiguation.cpp | 10 +++++-----
llvm/test/ThinLTO/X86/memprof-basic.ll | 3 +++
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index b803c97a7bd99..b1a4877f0675a 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -2073,14 +2073,14 @@ std::string IndexCallsiteContextGraph::getLabel(const FunctionSummary *Func,
unsigned CloneNo) const {
auto VI = FSToVIMap.find(Func);
assert(VI != FSToVIMap.end());
+ auto CallerName = getMemProfFuncName(VI->second.name(), CloneNo);
if (isa<AllocInfo *>(Call))
- return (VI->second.name() + " -> alloc").str();
+ return CallerName + " -> alloc";
else {
auto *Callsite = dyn_cast_if_present<CallsiteInfo *>(Call);
- return (VI->second.name() + " -> " +
- getMemProfFuncName(Callsite->Callee.name(),
- Callsite->Clones[CloneNo]))
- .str();
+ return CallerName + " -> " +
+ getMemProfFuncName(Callsite->Callee.name(),
+ Callsite->Clones[CloneNo]);
}
}
diff --git a/llvm/test/ThinLTO/X86/memprof-basic.ll b/llvm/test/ThinLTO/X86/memprof-basic.ll
index c5eedb2841b8c..67ae64f64479f 100644
--- a/llvm/test/ThinLTO/X86/memprof-basic.ll
+++ b/llvm/test/ThinLTO/X86/memprof-basic.ll
@@ -52,6 +52,7 @@
; RUN: cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOT
;; We should have cloned bar, baz, and foo, for the cold memory allocation.
; RUN: cat %t.ccg.cloned.dot | FileCheck %s --check-prefix=DOTCLONED
+; RUN: cat %t.ccg.clonefuncassign.dot | FileCheck %s --check-prefix=DOTFUNCASSIGN
; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --check-prefix=IR
@@ -370,6 +371,8 @@ attributes #0 = { noinline optnone }
; DOTCLONED: Node[[BAR2]] [shape=record,tooltip="N[[BAR2]] ContextIds: 2",fillcolor="cyan",color="blue",style="filled,bold,dashed",label="{OrigId: Alloc0\n_Z3barv -\> alloc}"];
; DOTCLONED: }
+; DOTFUNCASSIGN: _Z3bazv.memprof.1 -\> _Z3barv.memprof.1
+; DOTFUNCASSIGN: _Z3barv.memprof.1 -\> alloc
; DISTRIB: ^[[BAZ:[0-9]+]] = gv: (guid: 1807954217441101578, {{.*}} callsites: ((callee: ^[[BAR:[0-9]+]], clones: (0, 1)
; DISTRIB: ^[[FOO:[0-9]+]] = gv: (guid: 8107868197919466657, {{.*}} callsites: ((callee: ^[[BAZ]], clones: (0, 1)
>From 6c585d452bf0445c0be7cbb691d5ec5e24b873fb Mon Sep 17 00:00:00 2001
From: Teresa Johnson <tejohnson at google.com>
Date: Thu, 24 Jul 2025 11:29:33 -0700
Subject: [PATCH 2/3] Add comment to test
---
llvm/test/ThinLTO/X86/memprof-basic.ll | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/test/ThinLTO/X86/memprof-basic.ll b/llvm/test/ThinLTO/X86/memprof-basic.ll
index 67ae64f64479f..757f6e9322b23 100644
--- a/llvm/test/ThinLTO/X86/memprof-basic.ll
+++ b/llvm/test/ThinLTO/X86/memprof-basic.ll
@@ -371,6 +371,8 @@ attributes #0 = { noinline optnone }
; DOTCLONED: Node[[BAR2]] [shape=record,tooltip="N[[BAR2]] ContextIds: 2",fillcolor="cyan",color="blue",style="filled,bold,dashed",label="{OrigId: Alloc0\n_Z3barv -\> alloc}"];
; DOTCLONED: }
+;; Here we are just ensuring that the post-function assign dot graph includes
+;; clone information for both the caller and callee in the node labels.
; DOTFUNCASSIGN: _Z3bazv.memprof.1 -\> _Z3barv.memprof.1
; DOTFUNCASSIGN: _Z3barv.memprof.1 -\> alloc
>From 5e436ad85c7db1cf67d378a06ff4010f89bc2b84 Mon Sep 17 00:00:00 2001
From: Teresa Johnson <tejohnson at google.com>
Date: Thu, 24 Jul 2025 21:19:05 -0700
Subject: [PATCH 3/3] Address comment
---
llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index b1a4877f0675a..0164fcd71419e 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -2073,7 +2073,7 @@ std::string IndexCallsiteContextGraph::getLabel(const FunctionSummary *Func,
unsigned CloneNo) const {
auto VI = FSToVIMap.find(Func);
assert(VI != FSToVIMap.end());
- auto CallerName = getMemProfFuncName(VI->second.name(), CloneNo);
+ std::string CallerName = getMemProfFuncName(VI->second.name(), CloneNo);
if (isa<AllocInfo *>(Call))
return CallerName + " -> alloc";
else {
More information about the llvm-commits
mailing list