Index: lib/ProfileData/SampleProfWriter.cpp =================================================================== --- lib/ProfileData/SampleProfWriter.cpp +++ lib/ProfileData/SampleProfWriter.cpp @@ -222,7 +222,10 @@ } // 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; Index: test/tools/llvm-profdata/Inputs/sample-profile.proftext =================================================================== --- test/tools/llvm-profdata/Inputs/sample-profile.proftext +++ test/tools/llvm-profdata/Inputs/sample-profile.proftext @@ -10,3 +10,7 @@ 6: 2080 7: 534 9: 2064 _Z3bari:1471 _Z3fooi:631 + 10: inline1:1000 + 1: 1000 + 10: inline2:2000 + 1: 2000