summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData/SampleProf.cpp
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2015-11-19 15:33:08 +0000
committerDiego Novillo <dnovillo@google.com>2015-11-19 15:33:08 +0000
commitef548d2918df430a7c25ce3dcbb68b639af2d150 (patch)
tree394c0e57b4d3141c61ec55d08275e18bc4b1f1f0 /llvm/lib/ProfileData/SampleProf.cpp
parent307f80eab1993a52fed51334dd587800551a2389 (diff)
downloadbcm5719-llvm-ef548d2918df430a7c25ce3dcbb68b639af2d150.tar.gz
bcm5719-llvm-ef548d2918df430a7c25ce3dcbb68b639af2d150.zip
SamplePGO - Sort samples by source location when emitting as text.
When dumping function samples or writing them out as text format, it helps if the samples are emitted sorted by source location. The sorting of the maps is a bit slow, so we only do it on demand. llvm-svn: 253568
Diffstat (limited to 'llvm/lib/ProfileData/SampleProf.cpp')
-rw-r--r--llvm/lib/ProfileData/SampleProf.cpp13
1 files changed, 8 insertions, 5 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);
}
}
OpenPOWER on IntegriCloud