Skip to content

Commit 9d6f264

Browse files
[MemProf] Print internal context id when reporting bytes hinted (#128188)
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.
1 parent 268853e commit 9d6f264

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,6 +2957,8 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::printTotalSizes(
29572957
if (allocTypeToUse(Node->AllocTypes) != AllocTypeFromCall)
29582958
OS << " marked " << getAllocTypeString((uint8_t)AllocTypeFromCall)
29592959
<< " due to cold byte percent";
2960+
// Print the internal context id to aid debugging and visualization.
2961+
OS << " (context id " << Id << ")";
29602962
OS << "\n";
29612963
}
29622964
}

llvm/test/ThinLTO/X86/memprof-basic.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ attributes #0 = { noinline optnone }
273273
; DUMP: Edge from Callee [[BAR2]] to Caller: [[BAZ2]] AllocTypes: Cold ContextIds: 2
274274
; DUMP: Clone of [[BAR]]
275275

276-
; SIZES: NotCold full allocation context 123 with total size 100 is NotCold after cloning
277-
; SIZES: Cold full allocation context 456 with total size 200 is Cold after cloning
278-
; SIZES: Cold full allocation context 789 with total size 300 is Cold after cloning
276+
; SIZES: NotCold full allocation context 123 with total size 100 is NotCold after cloning (context id 1)
277+
; SIZES: Cold full allocation context 456 with total size 200 is Cold after cloning (context id 2)
278+
; SIZES: Cold full allocation context 789 with total size 300 is Cold after cloning (context id 2)
279279

280280
; REMARKS: call in clone main assigned to call function clone _Z3foov.memprof.1
281281
; REMARKS: created clone _Z3barv.memprof.1

llvm/test/Transforms/MemProfContextDisambiguation/basic.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ attributes #6 = { builtin }
252252
; REMARKS: call in clone _Z3bazv assigned to call function clone _Z3barv
253253
; REMARKS: call in clone _Z3barv marked with memprof allocation attribute notcold
254254

255-
; SIZES: NotCold full allocation context 123 with total size 100 is NotCold after cloning
256-
; SIZES: Cold full allocation context 456 with total size 200 is Cold after cloning
257-
; SIZES: Cold full allocation context 789 with total size 300 is Cold after cloning
255+
; SIZES: NotCold full allocation context 123 with total size 100 is NotCold after cloning (context id 1)
256+
; SIZES: Cold full allocation context 456 with total size 200 is Cold after cloning (context id 2)
257+
; SIZES: Cold full allocation context 789 with total size 300 is Cold after cloning (context id 2)
258258

259259
; IR: define {{.*}} @main
260260
;; The first call to foo does not allocate cold memory. It should call the

0 commit comments

Comments
 (0)