summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/ProfileData')
-rw-r--r--llvm/lib/ProfileData/SampleProf.cpp13
-rw-r--r--llvm/lib/ProfileData/SampleProfWriter.cpp17
2 files changed, 18 insertions, 12 deletions
diff --git a/llvm/lib/ProfileData/SampleProf.cpp b/llvm/lib/ProfileData/SampleProf.cpp
index 3d75d230fb6..c376a8bbd98 100644
--- a/llvm/lib/ProfileData/SampleProf.cpp
+++ b/llvm/lib/ProfileData/SampleProf.cpp
@@ -108,15 +108,18 @@ void FunctionSamples::print(raw_ostream &OS, unsigned Indent) const {
OS << TotalSamples << ", " << TotalHeadSamples << ", " << BodySamples.size()
<< " sampled lines\n";
- for (const auto &SI : BodySamples) {
+ SampleSorter<LineLocation, SampleRecord> SortedBodySamples(BodySamples);
+ for (const auto &SI : SortedBodySamples.get()) {
OS.indent(Indent);
- OS << SI.first << ": " << SI.second;
+ OS << SI->first << ": " << SI->second;
}
- for (const auto &CS : CallsiteSamples) {
+ SampleSorter<CallsiteLocation, FunctionSamples> SortedCallsiteSamples(
+ CallsiteSamples);
+ for (const auto &CS : SortedCallsiteSamples.get()) {
OS.indent(Indent);
- OS << CS.first << ": ";
- CS.second.print(OS, Indent + 2);
+ OS << CS->first << ": ";
+ CS->second.print(OS, Indent + 2);
}
}
diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp
index b7f6db5eb33..c9f89233468 100644
--- a/llvm/lib/ProfileData/SampleProfWriter.cpp
+++ b/llvm/lib/ProfileData/SampleProfWriter.cpp
@@ -32,7 +32,7 @@ using namespace llvm;
/// \brief Write samples to a text file.
///
/// Note: it may be tempting to implement this in terms of
-/// FunctionSamples::dump(). Please don't. The dump functionality is intended
+/// FunctionSamples::print(). Please don't. The dump functionality is intended
/// for debugging and has no specified form.
///
/// The format used here is more structured and deliberate because
@@ -44,9 +44,10 @@ std::error_code SampleProfileWriterText::write(StringRef FName,
OS << ":" << S.getHeadSamples();
OS << "\n";
- for (const auto &I : S.getBodySamples()) {
- LineLocation Loc = I.first;
- const SampleRecord &Sample = I.second;
+ SampleSorter<LineLocation, SampleRecord> SortedSamples(S.getBodySamples());
+ for (const auto &I : SortedSamples.get()) {
+ LineLocation Loc = I->first;
+ const SampleRecord &Sample = I->second;
OS.indent(Indent + 1);
if (Loc.Discriminator == 0)
OS << Loc.LineOffset << ": ";
@@ -60,10 +61,12 @@ std::error_code SampleProfileWriterText::write(StringRef FName,
OS << "\n";
}
+ SampleSorter<CallsiteLocation, FunctionSamples> SortedCallsiteSamples(
+ S.getCallsiteSamples());
Indent += 1;
- for (const auto &I : S.getCallsiteSamples()) {
- CallsiteLocation Loc = I.first;
- const FunctionSamples &CalleeSamples = I.second;
+ for (const auto &I : SortedCallsiteSamples.get()) {
+ CallsiteLocation Loc = I->first;
+ const FunctionSamples &CalleeSamples = I->second;
OS.indent(Indent);
if (Loc.Discriminator == 0)
OS << Loc.LineOffset << ": ";
OpenPOWER on IntegriCloud