Skip to content

Commit 40886fb

Browse files
[llvm-profgen] Extend llvm-profgen to generate vtable profiles with data access events for non context-sensitive profiles using debug info (#148013)
An RFC is in https://discourse.llvm.org/t/rfc-vtable-type-profiling-for-samplefdo/87283 This change extends to process perf data with Intel [MEM_INST_RETIRED.ALL_LOADS](https://perfmon-events.intel.com/index.html?pltfrm=skylake_server.html&evnt=MEM_INST_RETIRED.ALL_LOADS) samples and produce sample profiles with vtable information for non context-sensitive SampleFDO profiles. * For feature parity across different hardwares, future work could incorporate support for AMD Instruction-Based Sampling (IBS) and Arm Statistical Profiling Extension (SPE). --------- Co-authored-by: Paschalis Mpeis <paschalis.mpeis@arm.com>
1 parent 7cdffde commit 40886fb

17 files changed

+519
-27
lines changed

llvm/include/llvm/ProfileData/SampleProf.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,21 @@ class FunctionSamples {
10411041
return VirtualCallsiteTypeCounts[mapIRLocToProfileLoc(Loc)];
10421042
}
10431043

1044+
/// At location \p Loc, add a type sample for the given \p Type with
1045+
/// \p Count. This function uses saturating add which clamp the result to
1046+
/// maximum uint64_t (the counter type), and inserts the saturating add result
1047+
/// to map. Returns counter_overflow to caller if the actual result is larger
1048+
/// than maximum uint64_t.
1049+
sampleprof_error addTypeSamplesAt(const LineLocation &Loc, FunctionId Type,
1050+
uint64_t Count) {
1051+
auto &TypeCounts = getTypeSamplesAt(Loc);
1052+
bool Overflowed = false;
1053+
TypeCounts[Type] = SaturatingMultiplyAdd(Count, /* Weight= */ (uint64_t)1,
1054+
TypeCounts[Type], &Overflowed);
1055+
return Overflowed ? sampleprof_error::counter_overflow
1056+
: sampleprof_error::success;
1057+
}
1058+
10441059
/// Scale \p Other sample counts by \p Weight and add the scaled result to the
10451060
/// type samples for \p Loc. Under the hoold, the caller-provided \p Loc will
10461061
/// be un-drifted before the type sample lookup if possible.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
PERF_RECORD_MMAP2 21450/21450: [0x260000(0x153000) @ 0x5f000 fd:01 21193997 0]: r-xp /path/to/dap.bin
2+
PERF_RECORD_MMAP2 21450/21450: [0x7ff768d52000(0x2000) @ 0 00:00 0 0]: r-xp [vdso]
3+
4+
26090f
5+
30efd4
6+
0x2608bb/0x26090f/P/-/-/2//- 0x3510ab/0x2608af/P/-/-/3//- 0x351059/0x351098/P/-/-/7//- 0x350f8c/0x350fb4/P/-/-/4//- 0x260bf4/0x350f40/P/-/-/1//- 0x260be4/0x260bf0/P/-/-/1//- 0x26085a/0x260be0/P/-/-/2//- 0x2608ac/0x260850/P/-/-/1//- 0x26084c/0x2608a4/P/-/-/2//- 0x2608a2/0x260840/P/-/-/5//- 0x260832/0x260894/P/-/-/1//- 0x26081b/0x26082e/P/-/-/1//- 0x260c52/0x260814/P/-/-/1//- 0x3508da/0x260c4c/P/-/-/8//- 0x350879/0x350887/P/-/-/3//- 0x260c47/0x350850/P/-/-/2//- 0x26080f/0x260c30/P/-/-/2//- 0x26088f/0x260800/P/-/-/7//- 0x26090a/0x260880/P/-/-/1//- 0x26091c/0x260900/P/-/-/1//- 0x2608bb/0x26090f/P/-/-/2//- 0x3510ab/0x2608af/P/-/-/3//- 0x351059/0x351098/P/-/-/7//- 0x350f8c/0x350fb4/P/-/-/4//- 0x260bf4/0x350f40/P/-/-/1//- 0x260be4/0x260bf0/P/-/-/1//- 0x26085a/0x260be0/P/-/-/2//- 0x2608ac/0x260850/P/-/-/1//- 0x26084c/0x2608a4/P/-/-/2//- 0x2608a2/0x260840/P/-/-/4//- 0x260832/0x260894/P/-/-/1//- 0x26081b/0x26082e/P/-/-/1//-
7+
8+
351098
9+
21
10+
0x351059/0x351098/P/-/-/7//- 0x350f8c/0x350fb4/P/-/-/4//- 0x260bf4/0x350f40/P/-/-/1//- 0x260be4/0x260bf0/P/-/-/1//- 0x26085a/0x260be0/P/-/-/2//- 0x2608ac/0x260850/P/-/-/1//- 0x26084c/0x2608a4/P/-/-/2//- 0x2608a2/0x260840/P/-/-/4//- 0x260832/0x260894/P/-/-/1//- 0x26081b/0x26082e/P/-/-/1//- 0x260c52/0x260814/P/-/-/1//- 0x3508da/0x260c4c/P/-/-/10//- 0x350879/0x350887/P/-/-/3//- 0x260c47/0x350850/P/-/-/3//- 0x26080f/0x260c30/P/-/-/1//- 0x26088f/0x260800/P/-/-/3//- 0x26090a/0x260880/P/-/-/1//- 0x26091c/0x260900/P/-/-/1//- 0x2608bb/0x26090f/P/-/-/2//- 0x3510ab/0x2608af/P/-/-/3//- 0x351059/0x351098/P/-/-/7//- 0x350f8c/0x350fb4/P/-/-/4//- 0x260bf4/0x350f40/P/-/-/1//- 0x260be4/0x260bf0/P/-/-/1//- 0x26087a/0x260be0/P/-/-/2//- 0x2608ac/0x260870/P/-/-/1//- 0x2607fc/0x2608a4/P/-/-/2//- 0x2608a2/0x2607f0/P/-/-/6//- 0x260832/0x260894/P/-/-/1//- 0x260c52/0x260827/P/-/-/1//- 0x3508da/0x260c4c/P/-/-/12//- 0x350879/0x350887/P/-/-/3//-
11+
12+
350f40
13+
26090f
14+
30efd4
15+
0x260bf4/0x350f40/P/-/-/1//- 0x260be4/0x260bf0/P/-/-/1//- 0x26087a/0x260be0/P/-/-/2//- 0x2608ac/0x260870/P/-/-/1//- 0x2607fc/0x2608a4/P/-/-/2//- 0x2608a2/0x2607f0/P/-/-/5//- 0x260832/0x260894/P/-/-/1//- 0x260c52/0x260827/P/-/-/1//- 0x3508da/0x260c4c/P/-/-/10//- 0x350879/0x350887/P/-/-/3//- 0x260c47/0x350850/P/-/-/2//- 0x260822/0x260c30/P/-/-/1//- 0x260808/0x26081d/P/-/-/1//- 0x26088f/0x260800/P/-/-/3//- 0x26090a/0x260880/P/-/-/1//- 0x26091c/0x260900/P/-/-/1//- 0x2608bb/0x26090f/P/-/-/2//- 0x3510ab/0x2608af/P/-/-/3//- 0x351059/0x351098/P/-/-/7//- 0x350f8c/0x350fb4/P/-/-/4//- 0x260bf4/0x350f40/P/-/-/1//- 0x260be4/0x260bf0/P/-/-/1//- 0x26085a/0x260be0/P/-/-/2//- 0x2608ac/0x260850/P/-/-/1//- 0x26084c/0x2608a4/P/-/-/2//- 0x2608a2/0x260840/P/-/-/4//- 0x260832/0x260894/P/-/-/1//- 0x26081b/0x26082e/P/-/-/1//- 0x260c52/0x260814/P/-/-/1//- 0x3508da/0x260c4c/P/-/-/10//- 0x350879/0x350887/P/-/-/3//- 0x260c47/0x350850/P/-/-/3//-
16+
17+
351098
18+
21
19+
0x351059/0x351098/P/-/-/7//- 0x350f8c/0x350fb4/P/-/-/4//- 0x260bf4/0x350f40/P/-/-/1//- 0x260be4/0x260bf0/P/-/-/1//- 0x26085a/0x260be0/P/-/-/2//- 0x2608ac/0x260850/P/-/-/1//- 0x26084c/0x2608a4/P/-/-/2//- 0x2608a2/0x260840/P/-/-/4//- 0x260832/0x260894/P/-/-/1//- 0x26081b/0x26082e/P/-/-/1//- 0x260c52/0x260814/P/-/-/1//- 0x3508da/0x260c4c/P/-/-/14//- 0x350879/0x350887/P/-/-/4//- 0x260c47/0x350850/P/-/-/4//- 0x26080f/0x260c30/P/-/-/2//- 0x26088f/0x260800/P/-/-/3//- 0x26090a/0x260880/P/-/-/1//- 0x26091c/0x260900/P/-/-/1//- 0x2608bb/0x26090f/P/-/-/2//- 0x3510ab/0x2608af/P/-/-/3//- 0x351059/0x351098/P/-/-/7//- 0x350f8c/0x350fb4/P/-/-/4//- 0x260bf4/0x350f40/P/-/-/1//- 0x260be4/0x260bf0/P/-/-/1//- 0x26085a/0x260be0/P/-/-/2//- 0x2608ac/0x260850/P/-/-/1//- 0x26084c/0x2608a4/P/-/-/2//- 0x2608a2/0x260840/P/-/-/4//- 0x260832/0x260894/P/-/-/1//- 0x26081b/0x26082e/P/-/-/1//- 0x260c52/0x260814/P/-/-/1//- 0x3508da/0x260c4c/P/-/-/14//-
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
0 0x7b10 [0x88]: PERF_RECORD_MMAP2 3446532/3446532: [0x200000(0x60000) @ 0 08:01 527501 0]: r--p /path/to/dap.bin
2+
0 0x7b98 [0x88]: PERF_RECORD_MMAP2 3446532/3446532: [0x260000(0x153000) @ 0x5f000 08:01 527501 0]: r-xp /path/to/dap.bin
3+
0 0x7c20 [0x88]: PERF_RECORD_MMAP2 3446532/3446532: [0x3b3000(0xc000) @ 0x1b1000 08:01 527501 0]: r--p /path/to/dap.bin
4+
0 0x7ca8 [0x88]: PERF_RECORD_MMAP2 3446532/3446532: [0x3bf000(0x3000) @ 0x1bc000 08:01 527501 0]: rw-p /path/to/dap.bin
5+
1282514021937402 0x8660 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
6+
1282514022939813 0x87b0 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3fb0
7+
1282514023932029 0x8a00 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3fb0
8+
1282514024937981 0x8d48 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3fb0
9+
1282514028925828 0x94c0 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3fb0
10+
1282514028934870 0x9678 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608ac period: 233 addr: 0x3b3fc0
11+
1282514029934094 0x9830 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3fb0
12+
1282514040934785 0xb1d0 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608ac period: 233 addr: 0x3b3fc0
13+
1282514052924510 0xcbb8 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
14+
1282514053932406 0xcfb0 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608ac period: 233 addr: 0x3b3fc0
15+
1282514063928248 0xe5c8 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
16+
1282514073928057 0xfd20 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
17+
1282514081925013 0x10f28 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
18+
1282514084927335 0x11678 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
19+
1282514088926926 0x11f90 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
20+
1282514089929492 0x12270 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
21+
1282514119919997 0x16610 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
22+
1282514120924169 0x16920 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
23+
1282514145923603 0x1a338 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
24+
1282514146917708 0x1a428 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
25+
1282514173914003 0x1e1b0 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
26+
1282514188915199 0x20488 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
27+
1282514210915866 0x236d8 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
28+
1282514212908181 0x23a50 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3f70
29+
1282514480886012 0x4a098 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608ac period: 233 addr: 0x3b3f80
30+
1282514840855333 0x7dd48 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608ac period: 233 addr: 0x3b3f80
31+
1282514955835364 0x8e380 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608ac period: 233 addr: 0x3b3f80
32+
1282514967839429 0x8fef8 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608ac period: 233 addr: 0x3b3f80
33+
1282515023830209 0x97f98 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608ac period: 233 addr: 0x3b3f80
34+
1282515356804308 0xc7b28 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608ac period: 233 addr: 0x3b3f80
35+
1282515410794371 0xcf590 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608ac period: 233 addr: 0x3b3f80
36+
1282515541786485 0xe2280 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608ac period: 233 addr: 0x3b3f80
37+
1282515703761203 0xf93c0 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002): 3446532/3446532: 0x2608ac period: 233 addr: 0x3b3f80
38.6 KB
Binary file not shown.
2.24 MB
Binary file not shown.

0 commit comments

Comments
 (0)