aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/SampleProf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/ProfileData/SampleProf.cpp')
-rw-r--r--llvm/lib/ProfileData/SampleProf.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/ProfileData/SampleProf.cpp b/llvm/lib/ProfileData/SampleProf.cpp
index 0c47df3..60c1393 100644
--- a/llvm/lib/ProfileData/SampleProf.cpp
+++ b/llvm/lib/ProfileData/SampleProf.cpp
@@ -91,6 +91,8 @@ class SampleProfErrorCategoryType : public std::error_category {
return "Zlib is unavailable";
case sampleprof_error::hash_mismatch:
return "Function hash mismatch";
+ case sampleprof_error::illegal_line_offset:
+ return "Illegal line offset in sample profile data";
}
llvm_unreachable("A value of sampleprof_error has no message.");
}
@@ -150,7 +152,7 @@ std::error_code SampleRecord::serialize(
LLVM_DUMP_METHOD void LineLocation::dump() const { print(dbgs()); }
#endif
-void LineLocation::serialize(raw_ostream &OS) {
+void LineLocation::serialize(raw_ostream &OS) const {
encodeULEB128(LineOffset, OS);
encodeULEB128(Discriminator, OS);
}
@@ -203,12 +205,14 @@ void FunctionSamples::print(raw_ostream &OS, unsigned Indent) const {
OS << "Samples collected in inlined callsites {\n";
SampleSorter<LineLocation, FunctionSamplesMap> SortedCallsiteSamples(
CallsiteSamples);
- for (const auto &CS : SortedCallsiteSamples.get()) {
- for (const auto &FS : CS->second) {
+ for (const auto *Element : SortedCallsiteSamples.get()) {
+ // Element is a pointer to a pair of LineLocation and FunctionSamplesMap.
+ const auto &[Loc, FunctionSampleMap] = *Element;
+ for (const FunctionSamples &FuncSample :
+ llvm::make_second_range(FunctionSampleMap)) {
OS.indent(Indent + 2);
- OS << CS->first << ": inlined callee: " << FS.second.getFunction()
- << ": ";
- FS.second.print(OS, Indent + 4);
+ OS << Loc << ": inlined callee: " << FuncSample.getFunction() << ": ";
+ FuncSample.print(OS, Indent + 4);
}
}
OS.indent(Indent);