[llvm] [MemProf] Print internal context id when reporting bytes hinted (PR #128188)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 21 07:48:42 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lto
Author: Teresa Johnson (teresajohnson)
<details>
<summary>Changes</summary>
During the whole program reporting of contexts when hinted byte
reporting is enabled via -memprof-report-hinted-sizes, also print the
internal context id. This is useful for debugging, as well as for
guiding the dot file dumping with some upcoming changes that will
accept a context id to focus the graph on a context of interest.
---
Full diff: https://github.com/llvm/llvm-project/pull/128188.diff
3 Files Affected:
- (modified) llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp (+2)
- (modified) llvm/test/ThinLTO/X86/memprof-basic.ll (+3-3)
- (modified) llvm/test/Transforms/MemProfContextDisambiguation/basic.ll (+3-3)
``````````diff
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index 2e18d3af36a92..a663a0de17a8e 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -2949,6 +2949,8 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::printTotalSizes(
if (allocTypeToUse(Node->AllocTypes) != AllocTypeFromCall)
OS << " marked " << getAllocTypeString((uint8_t)AllocTypeFromCall)
<< " due to cold byte percent";
+ // Print the internal context id to aid debugging and visualization.
+ OS << " (context id " << Id << ")";
OS << "\n";
}
}
diff --git a/llvm/test/ThinLTO/X86/memprof-basic.ll b/llvm/test/ThinLTO/X86/memprof-basic.ll
index 6de301340acf3..b586be001aa71 100644
--- a/llvm/test/ThinLTO/X86/memprof-basic.ll
+++ b/llvm/test/ThinLTO/X86/memprof-basic.ll
@@ -273,9 +273,9 @@ attributes #0 = { noinline optnone }
; DUMP: Edge from Callee [[BAR2]] to Caller: [[BAZ2]] AllocTypes: Cold ContextIds: 2
; DUMP: Clone of [[BAR]]
-; SIZES: NotCold full allocation context 123 with total size 100 is NotCold after cloning
-; SIZES: Cold full allocation context 456 with total size 200 is Cold after cloning
-; SIZES: Cold full allocation context 789 with total size 300 is Cold after cloning
+; SIZES: NotCold full allocation context 123 with total size 100 is NotCold after cloning (context id 1)
+; SIZES: Cold full allocation context 456 with total size 200 is Cold after cloning (context id 2)
+; SIZES: Cold full allocation context 789 with total size 300 is Cold after cloning (context id 2)
; REMARKS: call in clone main assigned to call function clone _Z3foov.memprof.1
; REMARKS: created clone _Z3barv.memprof.1
diff --git a/llvm/test/Transforms/MemProfContextDisambiguation/basic.ll b/llvm/test/Transforms/MemProfContextDisambiguation/basic.ll
index 952e2519bbf0b..a97feda6173bb 100644
--- a/llvm/test/Transforms/MemProfContextDisambiguation/basic.ll
+++ b/llvm/test/Transforms/MemProfContextDisambiguation/basic.ll
@@ -252,9 +252,9 @@ attributes #6 = { builtin }
; REMARKS: call in clone _Z3bazv assigned to call function clone _Z3barv
; REMARKS: call in clone _Z3barv marked with memprof allocation attribute notcold
-; SIZES: NotCold full allocation context 123 with total size 100 is NotCold after cloning
-; SIZES: Cold full allocation context 456 with total size 200 is Cold after cloning
-; SIZES: Cold full allocation context 789 with total size 300 is Cold after cloning
+; SIZES: NotCold full allocation context 123 with total size 100 is NotCold after cloning (context id 1)
+; SIZES: Cold full allocation context 456 with total size 200 is Cold after cloning (context id 2)
+; SIZES: Cold full allocation context 789 with total size 300 is Cold after cloning (context id 2)
; IR: define {{.*}} @main
;; The first call to foo does not allocate cold memory. It should call the
``````````
</details>
https://github.com/llvm/llvm-project/pull/128188
More information about the llvm-commits
mailing list