[llvm] b889df3 - [MemProf] Add option to print function GUIDs during matching (#170946)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 5 19:57:06 PST 2025
Author: Teresa Johnson
Date: 2025-12-05T19:57:02-08:00
New Revision: b889df39d61ba4ca003473749ee620fab87895b0
URL: https://github.com/llvm/llvm-project/commit/b889df39d61ba4ca003473749ee620fab87895b0
DIFF: https://github.com/llvm/llvm-project/commit/b889df39d61ba4ca003473749ee620fab87895b0.diff
LOG: [MemProf] Add option to print function GUIDs during matching (#170946)
For debugging, add -memprof-print-function-guids option that will cause
memprof matching to emit the computed function GUID for every function
definition in the module to stderr. This is helpful because the profile
only contains the function GUID and not the names.
Added:
Modified:
llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
llvm/test/Transforms/PGOProfile/memprof-dump-matched-alloc-site.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
index 31e69784262da..c3ff90ea35a72 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
@@ -62,6 +62,11 @@ static cl::opt<bool>
"context in this module's profiles"),
cl::Hidden, cl::init(false));
+static cl::opt<bool>
+ PrintFunctionGuids("memprof-print-function-guids",
+ cl::desc("Print function GUIDs computed for matching"),
+ cl::Hidden, cl::init(false));
+
static cl::opt<bool>
SalvageStaleProfile("memprof-salvage-stale-profile",
cl::desc("Salvage stale MemProf profile"),
@@ -577,6 +582,9 @@ static void readMemprof(Module &M, Function &F,
// linkage function.
auto FuncName = F.getName();
auto FuncGUID = Function::getGUIDAssumingExternalLinkage(FuncName);
+ if (PrintFunctionGuids)
+ errs() << "MemProf: Function GUID " << FuncGUID << " is " << FuncName
+ << "\n";
std::optional<memprof::MemProfRecord> MemProfRec;
auto Err = MemProfReader->getMemProfRecord(FuncGUID).moveInto(MemProfRec);
if (Err) {
diff --git a/llvm/test/Transforms/PGOProfile/memprof-dump-matched-alloc-site.ll b/llvm/test/Transforms/PGOProfile/memprof-dump-matched-alloc-site.ll
index 10cafff3490b3..f628c5a8a3251 100644
--- a/llvm/test/Transforms/PGOProfile/memprof-dump-matched-alloc-site.ll
+++ b/llvm/test/Transforms/PGOProfile/memprof-dump-matched-alloc-site.ll
@@ -26,7 +26,7 @@
; REQUIRES: x86_64-linux
; RUN: split-file %s %t
; RUN: llvm-profdata merge %t/memprof-dump-matched-alloc-site.yaml -o %t/memprof-dump-matched-alloc-site.memprofdata
-; RUN: opt < %t/memprof-dump-matched-alloc-site.ll -passes='memprof-use<profile-filename=%t/memprof-dump-matched-alloc-site.memprofdata>' -memprof-print-match-info -S -pass-remarks=memprof 2>&1 | FileCheck %s
+; RUN: opt < %t/memprof-dump-matched-alloc-site.ll -passes='memprof-use<profile-filename=%t/memprof-dump-matched-alloc-site.memprofdata>' -memprof-print-match-info -memprof-print-function-guids -S -pass-remarks=memprof 2>&1 | FileCheck %s
;--- memprof-dump-matched-alloc-site.yaml
---
@@ -78,9 +78,12 @@ HeapProfileRecords:
...
;--- memprof-dump-matched-alloc-site.ll
-;; From -pass-remarks=memprof
+;; From -pass-remarks=memprof and -memprof-print-function-guids
+; CHECK: MemProf: Function GUID 4708092051066754107 is _Z2f1v
; CHECK: remark: memprof-dump-matched-alloc-site.cc:1:21: call in function _Z2f1v matched alloc context with alloc type notcold total size 3 full context id 5736731103568718490 frame count 1
+; CHECK: MemProf: Function GUID 14255129117669598641 is _Z2f2v
; CHECK: remark: memprof-dump-matched-alloc-site.cc:1:21: call in function _Z2f2v matched alloc context with alloc type notcold total size 3 full context id 5736731103568718490 frame count 2
+; CHECK: MemProf: Function GUID 2771528421763978342 is _Z2f3v
; CHECK: remark: memprof-dump-matched-alloc-site.cc:1:21: call in function _Z2f3v matched alloc context with alloc type notcold total size 3 full context id 5736731103568718490 frame count 3
;; From -memprof-print-match-info
More information about the llvm-commits
mailing list