diff options
author | Dehao Chen <dehao@google.com> | 2017-08-03 00:09:18 +0000 |
---|---|---|
committer | Dehao Chen <dehao@google.com> | 2017-08-03 00:09:18 +0000 |
commit | 2c27daf7c0dd74c42f454c13c0f4d8ca15d38f31 (patch) | |
tree | 4df77aaceb9779ca6e941189f6b7ba5ae5d83532 | |
parent | 4cc7222872819e4242816e4ca5ae3fe3e21bb271 (diff) | |
download | bcm5719-llvm-2c27daf7c0dd74c42f454c13c0f4d8ca15d38f31.tar.gz bcm5719-llvm-2c27daf7c0dd74c42f454c13c0f4d8ca15d38f31.zip |
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
llvm-svn: 309907
-rw-r--r-- | llvm/lib/ProfileData/SampleProfWriter.cpp | 5 | ||||
-rw-r--r-- | llvm/test/tools/llvm-profdata/Inputs/sample-profile.proftext | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp index b45026140c9..b9d357ab15e 100644 --- a/llvm/lib/ProfileData/SampleProfWriter.cpp +++ b/llvm/lib/ProfileData/SampleProfWriter.cpp @@ -222,7 +222,10 @@ std::error_code SampleProfileWriterBinary::writeBody(const FunctionSamples &S) { } // Recursively emit all the callsite samples. - encodeULEB128(S.getCallsiteSamples().size(), OS); + uint64_t NumCallsites = 0; + for (const auto &J : S.getCallsiteSamples()) + NumCallsites += J.second.size(); + encodeULEB128(NumCallsites, OS); for (const auto &J : S.getCallsiteSamples()) for (const auto &FS : J.second) { LineLocation Loc = J.first; diff --git a/llvm/test/tools/llvm-profdata/Inputs/sample-profile.proftext b/llvm/test/tools/llvm-profdata/Inputs/sample-profile.proftext index 54c821243af..e34128faabc 100644 --- a/llvm/test/tools/llvm-profdata/Inputs/sample-profile.proftext +++ b/llvm/test/tools/llvm-profdata/Inputs/sample-profile.proftext @@ -10,3 +10,7 @@ main:184019:0 6: 2080 7: 534 9: 2064 _Z3bari:1471 _Z3fooi:631 + 10: inline1:1000 + 1: 1000 + 10: inline2:2000 + 1: 2000 |