Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit ca9f2fd

Browse files
committed
Fix the bug when SampleProfileWriter writes out number of callsites.
Summary: As we support multiple callsites for the same location, we need to traverse all locations to get the number of callsites. Reviewers: davidxl Reviewed By: davidxl Subscribers: sanjoy, llvm-commits Differential Revision: https://reviews.llvm.org/D36246 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309907 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d7247b5 commit ca9f2fd

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/ProfileData/SampleProfWriter.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,10 @@ std::error_code SampleProfileWriterBinary::writeBody(const FunctionSamples &S) {
222222
}
223223

224224
// Recursively emit all the callsite samples.
225-
encodeULEB128(S.getCallsiteSamples().size(), OS);
225+
uint64_t NumCallsites = 0;
226+
for (const auto &J : S.getCallsiteSamples())
227+
NumCallsites += J.second.size();
228+
encodeULEB128(NumCallsites, OS);
226229
for (const auto &J : S.getCallsiteSamples())
227230
for (const auto &FS : J.second) {
228231
LineLocation Loc = J.first;

test/tools/llvm-profdata/Inputs/sample-profile.proftext

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ main:184019:0
1010
6: 2080
1111
7: 534
1212
9: 2064 _Z3bari:1471 _Z3fooi:631
13+
10: inline1:1000
14+
1: 1000
15+
10: inline2:2000
16+
1: 2000

0 commit comments

Comments
 (0)