Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 1 | //===- SampleProfWriter.cpp - Write LLVM sample profile data --------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the class that writes LLVM sample profiles. It |
| 11 | // supports two file formats: text and binary. The textual representation |
| 12 | // is useful for debugging and testing purposes. The binary representation |
| 13 | // is more compact, resulting in smaller file sizes. However, they can |
| 14 | // both be used interchangeably. |
| 15 | // |
| 16 | // See lib/ProfileData/SampleProfReader.cpp for documentation on each of the |
| 17 | // supported formats. |
| 18 | // |
| 19 | //===----------------------------------------------------------------------===// |
| 20 | |
Chandler Carruth | 6bda14b | 2017-06-06 11:49:48 +0000 | [diff] [blame^] | 21 | #include "llvm/ProfileData/SampleProfWriter.h" |
Eugene Zelenko | e78d131 | 2017-03-03 01:07:34 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/StringRef.h" |
| 23 | #include "llvm/ProfileData/ProfileCommon.h" |
| 24 | #include "llvm/ProfileData/SampleProf.h" |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 25 | #include "llvm/Support/ErrorOr.h" |
Eugene Zelenko | e78d131 | 2017-03-03 01:07:34 +0000 | [diff] [blame] | 26 | #include "llvm/Support/FileSystem.h" |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 27 | #include "llvm/Support/LEB128.h" |
Eugene Zelenko | e78d131 | 2017-03-03 01:07:34 +0000 | [diff] [blame] | 28 | #include "llvm/Support/raw_ostream.h" |
| 29 | #include <algorithm> |
| 30 | #include <cstdint> |
| 31 | #include <memory> |
Dehao Chen | 8d1c983 | 2017-05-11 23:43:44 +0000 | [diff] [blame] | 32 | #include <set> |
Eugene Zelenko | e78d131 | 2017-03-03 01:07:34 +0000 | [diff] [blame] | 33 | #include <system_error> |
| 34 | #include <utility> |
| 35 | #include <vector> |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 36 | |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 37 | using namespace llvm; |
Eugene Zelenko | e78d131 | 2017-03-03 01:07:34 +0000 | [diff] [blame] | 38 | using namespace sampleprof; |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 39 | |
Dehao Chen | 8d1c983 | 2017-05-11 23:43:44 +0000 | [diff] [blame] | 40 | std::error_code |
| 41 | SampleProfileWriter::write(const StringMap<FunctionSamples> &ProfileMap) { |
| 42 | if (std::error_code EC = writeHeader(ProfileMap)) |
| 43 | return EC; |
| 44 | |
| 45 | // Sort the ProfileMap by total samples. |
| 46 | typedef std::pair<StringRef, const FunctionSamples *> NameFunctionSamples; |
| 47 | std::vector<NameFunctionSamples> V; |
| 48 | for (const auto &I : ProfileMap) |
| 49 | V.push_back(std::make_pair(I.getKey(), &I.second)); |
| 50 | |
| 51 | std::stable_sort( |
| 52 | V.begin(), V.end(), |
| 53 | [](const NameFunctionSamples &A, const NameFunctionSamples &B) { |
| 54 | if (A.second->getTotalSamples() == B.second->getTotalSamples()) |
| 55 | return A.first > B.first; |
| 56 | return A.second->getTotalSamples() > B.second->getTotalSamples(); |
| 57 | }); |
| 58 | |
| 59 | for (const auto &I : V) { |
| 60 | if (std::error_code EC = write(*I.second)) |
| 61 | return EC; |
| 62 | } |
| 63 | return sampleprof_error::success; |
| 64 | } |
| 65 | |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 66 | /// \brief Write samples to a text file. |
Diego Novillo | 8e415a8 | 2015-11-13 20:24:28 +0000 | [diff] [blame] | 67 | /// |
| 68 | /// Note: it may be tempting to implement this in terms of |
Diego Novillo | ef548d2 | 2015-11-19 15:33:08 +0000 | [diff] [blame] | 69 | /// FunctionSamples::print(). Please don't. The dump functionality is intended |
Diego Novillo | 8e415a8 | 2015-11-13 20:24:28 +0000 | [diff] [blame] | 70 | /// for debugging and has no specified form. |
| 71 | /// |
| 72 | /// The format used here is more structured and deliberate because |
| 73 | /// it needs to be parsed by the SampleProfileReaderText class. |
Dehao Chen | 57d1dda | 2016-03-03 18:09:32 +0000 | [diff] [blame] | 74 | std::error_code SampleProfileWriterText::write(const FunctionSamples &S) { |
Nathan Slingerland | 51abea7 | 2015-12-10 17:21:42 +0000 | [diff] [blame] | 75 | auto &OS = *OutputStream; |
Dehao Chen | 57d1dda | 2016-03-03 18:09:32 +0000 | [diff] [blame] | 76 | OS << S.getName() << ":" << S.getTotalSamples(); |
Diego Novillo | aae1ed8 | 2015-10-08 19:40:37 +0000 | [diff] [blame] | 77 | if (Indent == 0) |
| 78 | OS << ":" << S.getHeadSamples(); |
| 79 | OS << "\n"; |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 80 | |
Diego Novillo | ef548d2 | 2015-11-19 15:33:08 +0000 | [diff] [blame] | 81 | SampleSorter<LineLocation, SampleRecord> SortedSamples(S.getBodySamples()); |
| 82 | for (const auto &I : SortedSamples.get()) { |
| 83 | LineLocation Loc = I->first; |
| 84 | const SampleRecord &Sample = I->second; |
Diego Novillo | aae1ed8 | 2015-10-08 19:40:37 +0000 | [diff] [blame] | 85 | OS.indent(Indent + 1); |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 86 | if (Loc.Discriminator == 0) |
| 87 | OS << Loc.LineOffset << ": "; |
| 88 | else |
| 89 | OS << Loc.LineOffset << "." << Loc.Discriminator << ": "; |
| 90 | |
| 91 | OS << Sample.getSamples(); |
| 92 | |
Diego Novillo | d5336ae | 2014-11-01 00:56:55 +0000 | [diff] [blame] | 93 | for (const auto &J : Sample.getCallTargets()) |
| 94 | OS << " " << J.first() << ":" << J.second; |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 95 | OS << "\n"; |
| 96 | } |
| 97 | |
Dehao Chen | 2c7ca9b | 2017-04-13 19:52:10 +0000 | [diff] [blame] | 98 | SampleSorter<LineLocation, FunctionSamplesMap> SortedCallsiteSamples( |
Diego Novillo | ef548d2 | 2015-11-19 15:33:08 +0000 | [diff] [blame] | 99 | S.getCallsiteSamples()); |
Diego Novillo | aae1ed8 | 2015-10-08 19:40:37 +0000 | [diff] [blame] | 100 | Indent += 1; |
Dehao Chen | 2c7ca9b | 2017-04-13 19:52:10 +0000 | [diff] [blame] | 101 | for (const auto &I : SortedCallsiteSamples.get()) |
| 102 | for (const auto &FS : I->second) { |
| 103 | LineLocation Loc = I->first; |
| 104 | const FunctionSamples &CalleeSamples = FS.second; |
| 105 | OS.indent(Indent); |
| 106 | if (Loc.Discriminator == 0) |
| 107 | OS << Loc.LineOffset << ": "; |
| 108 | else |
| 109 | OS << Loc.LineOffset << "." << Loc.Discriminator << ": "; |
| 110 | if (std::error_code EC = write(CalleeSamples)) |
| 111 | return EC; |
| 112 | } |
Diego Novillo | aae1ed8 | 2015-10-08 19:40:37 +0000 | [diff] [blame] | 113 | Indent -= 1; |
| 114 | |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 115 | return sampleprof_error::success; |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 116 | } |
| 117 | |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 118 | std::error_code SampleProfileWriterBinary::writeNameIdx(StringRef FName) { |
| 119 | const auto &ret = NameTable.find(FName); |
| 120 | if (ret == NameTable.end()) |
| 121 | return sampleprof_error::truncated_name_table; |
Nathan Slingerland | 51abea7 | 2015-12-10 17:21:42 +0000 | [diff] [blame] | 122 | encodeULEB128(ret->second, *OutputStream); |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 123 | return sampleprof_error::success; |
| 124 | } |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 125 | |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 126 | void SampleProfileWriterBinary::addName(StringRef FName) { |
Dehao Chen | 8d1c983 | 2017-05-11 23:43:44 +0000 | [diff] [blame] | 127 | NameTable.insert(std::make_pair(FName, 0)); |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | void SampleProfileWriterBinary::addNames(const FunctionSamples &S) { |
| 131 | // Add all the names in indirect call targets. |
| 132 | for (const auto &I : S.getBodySamples()) { |
| 133 | const SampleRecord &Sample = I.second; |
| 134 | for (const auto &J : Sample.getCallTargets()) |
| 135 | addName(J.first()); |
| 136 | } |
| 137 | |
| 138 | // Recursively add all the names for inlined callsites. |
Dehao Chen | 2c7ca9b | 2017-04-13 19:52:10 +0000 | [diff] [blame] | 139 | for (const auto &J : S.getCallsiteSamples()) |
| 140 | for (const auto &FS : J.second) { |
| 141 | const FunctionSamples &CalleeSamples = FS.second; |
| 142 | addName(CalleeSamples.getName()); |
| 143 | addNames(CalleeSamples); |
| 144 | } |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | std::error_code SampleProfileWriterBinary::writeHeader( |
| 148 | const StringMap<FunctionSamples> &ProfileMap) { |
Nathan Slingerland | 51abea7 | 2015-12-10 17:21:42 +0000 | [diff] [blame] | 149 | auto &OS = *OutputStream; |
| 150 | |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 151 | // Write file magic identifier. |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 152 | encodeULEB128(SPMagic(), OS); |
| 153 | encodeULEB128(SPVersion(), OS); |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 154 | |
Easwaran Raman | 40ee23d | 2016-02-19 03:15:33 +0000 | [diff] [blame] | 155 | computeSummary(ProfileMap); |
| 156 | if (auto EC = writeSummary()) |
| 157 | return EC; |
| 158 | |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 159 | // Generate the name table for all the functions referenced in the profile. |
| 160 | for (const auto &I : ProfileMap) { |
| 161 | addName(I.first()); |
| 162 | addNames(I.second); |
| 163 | } |
| 164 | |
Dehao Chen | 8d1c983 | 2017-05-11 23:43:44 +0000 | [diff] [blame] | 165 | // Sort the names to make NameTable is deterministic. |
| 166 | std::set<StringRef> V; |
| 167 | for (const auto &I : NameTable) |
| 168 | V.insert(I.first); |
| 169 | int i = 0; |
| 170 | for (const StringRef &N : V) |
| 171 | NameTable[N] = i++; |
| 172 | |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 173 | // Write out the name table. |
| 174 | encodeULEB128(NameTable.size(), OS); |
Dehao Chen | 8d1c983 | 2017-05-11 23:43:44 +0000 | [diff] [blame] | 175 | for (auto N : V) { |
| 176 | OS << N; |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 177 | encodeULEB128(0, OS); |
| 178 | } |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 179 | return sampleprof_error::success; |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 180 | } |
| 181 | |
Easwaran Raman | 40ee23d | 2016-02-19 03:15:33 +0000 | [diff] [blame] | 182 | std::error_code SampleProfileWriterBinary::writeSummary() { |
| 183 | auto &OS = *OutputStream; |
Easwaran Raman | 7cefdb8 | 2016-05-19 21:53:28 +0000 | [diff] [blame] | 184 | encodeULEB128(Summary->getTotalCount(), OS); |
| 185 | encodeULEB128(Summary->getMaxCount(), OS); |
Easwaran Raman | 6f4903d | 2016-03-28 23:14:29 +0000 | [diff] [blame] | 186 | encodeULEB128(Summary->getMaxFunctionCount(), OS); |
Easwaran Raman | 7cefdb8 | 2016-05-19 21:53:28 +0000 | [diff] [blame] | 187 | encodeULEB128(Summary->getNumCounts(), OS); |
Easwaran Raman | 40ee23d | 2016-02-19 03:15:33 +0000 | [diff] [blame] | 188 | encodeULEB128(Summary->getNumFunctions(), OS); |
| 189 | std::vector<ProfileSummaryEntry> &Entries = Summary->getDetailedSummary(); |
| 190 | encodeULEB128(Entries.size(), OS); |
| 191 | for (auto Entry : Entries) { |
| 192 | encodeULEB128(Entry.Cutoff, OS); |
| 193 | encodeULEB128(Entry.MinCount, OS); |
| 194 | encodeULEB128(Entry.NumCounts, OS); |
| 195 | } |
| 196 | return sampleprof_error::success; |
| 197 | } |
Dehao Chen | 57d1dda | 2016-03-03 18:09:32 +0000 | [diff] [blame] | 198 | std::error_code SampleProfileWriterBinary::writeBody(const FunctionSamples &S) { |
Nathan Slingerland | 51abea7 | 2015-12-10 17:21:42 +0000 | [diff] [blame] | 199 | auto &OS = *OutputStream; |
| 200 | |
Dehao Chen | 57d1dda | 2016-03-03 18:09:32 +0000 | [diff] [blame] | 201 | if (std::error_code EC = writeNameIdx(S.getName())) |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 202 | return EC; |
| 203 | |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 204 | encodeULEB128(S.getTotalSamples(), OS); |
Diego Novillo | a7f1e8e | 2015-10-09 17:54:24 +0000 | [diff] [blame] | 205 | |
| 206 | // Emit all the body samples. |
Diego Novillo | b93483d | 2015-10-16 18:54:35 +0000 | [diff] [blame] | 207 | encodeULEB128(S.getBodySamples().size(), OS); |
Diego Novillo | d5336ae | 2014-11-01 00:56:55 +0000 | [diff] [blame] | 208 | for (const auto &I : S.getBodySamples()) { |
| 209 | LineLocation Loc = I.first; |
| 210 | const SampleRecord &Sample = I.second; |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 211 | encodeULEB128(Loc.LineOffset, OS); |
| 212 | encodeULEB128(Loc.Discriminator, OS); |
| 213 | encodeULEB128(Sample.getSamples(), OS); |
| 214 | encodeULEB128(Sample.getCallTargets().size(), OS); |
Diego Novillo | d5336ae | 2014-11-01 00:56:55 +0000 | [diff] [blame] | 215 | for (const auto &J : Sample.getCallTargets()) { |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 216 | StringRef Callee = J.first(); |
Diego Novillo | 38be333 | 2015-10-15 16:36:21 +0000 | [diff] [blame] | 217 | uint64_t CalleeSamples = J.second; |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 218 | if (std::error_code EC = writeNameIdx(Callee)) |
| 219 | return EC; |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 220 | encodeULEB128(CalleeSamples, OS); |
| 221 | } |
| 222 | } |
| 223 | |
Diego Novillo | a7f1e8e | 2015-10-09 17:54:24 +0000 | [diff] [blame] | 224 | // Recursively emit all the callsite samples. |
| 225 | encodeULEB128(S.getCallsiteSamples().size(), OS); |
Dehao Chen | 2c7ca9b | 2017-04-13 19:52:10 +0000 | [diff] [blame] | 226 | for (const auto &J : S.getCallsiteSamples()) |
| 227 | for (const auto &FS : J.second) { |
| 228 | LineLocation Loc = J.first; |
| 229 | const FunctionSamples &CalleeSamples = FS.second; |
| 230 | encodeULEB128(Loc.LineOffset, OS); |
| 231 | encodeULEB128(Loc.Discriminator, OS); |
| 232 | if (std::error_code EC = writeBody(CalleeSamples)) |
| 233 | return EC; |
| 234 | } |
Diego Novillo | a7f1e8e | 2015-10-09 17:54:24 +0000 | [diff] [blame] | 235 | |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 236 | return sampleprof_error::success; |
Diego Novillo | c572e92 | 2014-10-30 18:00:06 +0000 | [diff] [blame] | 237 | } |
Diego Novillo | d5336ae | 2014-11-01 00:56:55 +0000 | [diff] [blame] | 238 | |
Diego Novillo | b93483d | 2015-10-16 18:54:35 +0000 | [diff] [blame] | 239 | /// \brief Write samples of a top-level function to a binary file. |
| 240 | /// |
| 241 | /// \returns true if the samples were written successfully, false otherwise. |
Dehao Chen | 57d1dda | 2016-03-03 18:09:32 +0000 | [diff] [blame] | 242 | std::error_code SampleProfileWriterBinary::write(const FunctionSamples &S) { |
Nathan Slingerland | 51abea7 | 2015-12-10 17:21:42 +0000 | [diff] [blame] | 243 | encodeULEB128(S.getHeadSamples(), *OutputStream); |
Dehao Chen | 57d1dda | 2016-03-03 18:09:32 +0000 | [diff] [blame] | 244 | return writeBody(S); |
Diego Novillo | b93483d | 2015-10-16 18:54:35 +0000 | [diff] [blame] | 245 | } |
| 246 | |
Nathan Slingerland | 51abea7 | 2015-12-10 17:21:42 +0000 | [diff] [blame] | 247 | /// \brief Create a sample profile file writer based on the specified format. |
Diego Novillo | d5336ae | 2014-11-01 00:56:55 +0000 | [diff] [blame] | 248 | /// |
| 249 | /// \param Filename The file to create. |
| 250 | /// |
| 251 | /// \param Writer The writer to instantiate according to the specified format. |
| 252 | /// |
| 253 | /// \param Format Encoding format for the profile file. |
| 254 | /// |
| 255 | /// \returns an error code indicating the status of the created writer. |
Diego Novillo | fcd5560 | 2014-11-03 00:51:45 +0000 | [diff] [blame] | 256 | ErrorOr<std::unique_ptr<SampleProfileWriter>> |
| 257 | SampleProfileWriter::create(StringRef Filename, SampleProfileFormat Format) { |
Diego Novillo | d5336ae | 2014-11-01 00:56:55 +0000 | [diff] [blame] | 258 | std::error_code EC; |
Nathan Slingerland | 51abea7 | 2015-12-10 17:21:42 +0000 | [diff] [blame] | 259 | std::unique_ptr<raw_ostream> OS; |
| 260 | if (Format == SPF_Binary) |
| 261 | OS.reset(new raw_fd_ostream(Filename, EC, sys::fs::F_None)); |
| 262 | else |
| 263 | OS.reset(new raw_fd_ostream(Filename, EC, sys::fs::F_Text)); |
| 264 | if (EC) |
| 265 | return EC; |
| 266 | |
| 267 | return create(OS, Format); |
| 268 | } |
| 269 | |
| 270 | /// \brief Create a sample profile stream writer based on the specified format. |
| 271 | /// |
| 272 | /// \param OS The output stream to store the profile data to. |
| 273 | /// |
| 274 | /// \param Writer The writer to instantiate according to the specified format. |
| 275 | /// |
| 276 | /// \param Format Encoding format for the profile file. |
| 277 | /// |
| 278 | /// \returns an error code indicating the status of the created writer. |
| 279 | ErrorOr<std::unique_ptr<SampleProfileWriter>> |
| 280 | SampleProfileWriter::create(std::unique_ptr<raw_ostream> &OS, |
| 281 | SampleProfileFormat Format) { |
| 282 | std::error_code EC; |
Diego Novillo | fcd5560 | 2014-11-03 00:51:45 +0000 | [diff] [blame] | 283 | std::unique_ptr<SampleProfileWriter> Writer; |
Diego Novillo | d5336ae | 2014-11-01 00:56:55 +0000 | [diff] [blame] | 284 | |
| 285 | if (Format == SPF_Binary) |
Nathan Slingerland | 51abea7 | 2015-12-10 17:21:42 +0000 | [diff] [blame] | 286 | Writer.reset(new SampleProfileWriterBinary(OS)); |
Diego Novillo | d5336ae | 2014-11-01 00:56:55 +0000 | [diff] [blame] | 287 | else if (Format == SPF_Text) |
Nathan Slingerland | 51abea7 | 2015-12-10 17:21:42 +0000 | [diff] [blame] | 288 | Writer.reset(new SampleProfileWriterText(OS)); |
Diego Novillo | 760c5a8 | 2015-10-13 22:48:46 +0000 | [diff] [blame] | 289 | else if (Format == SPF_GCC) |
| 290 | EC = sampleprof_error::unsupported_writing_format; |
Diego Novillo | d5336ae | 2014-11-01 00:56:55 +0000 | [diff] [blame] | 291 | else |
| 292 | EC = sampleprof_error::unrecognized_format; |
| 293 | |
Diego Novillo | fcd5560 | 2014-11-03 00:51:45 +0000 | [diff] [blame] | 294 | if (EC) |
| 295 | return EC; |
| 296 | |
| 297 | return std::move(Writer); |
Diego Novillo | d5336ae | 2014-11-01 00:56:55 +0000 | [diff] [blame] | 298 | } |
Easwaran Raman | 40ee23d | 2016-02-19 03:15:33 +0000 | [diff] [blame] | 299 | |
| 300 | void SampleProfileWriter::computeSummary( |
| 301 | const StringMap<FunctionSamples> &ProfileMap) { |
Easwaran Raman | e5a17e3 | 2016-05-19 21:07:12 +0000 | [diff] [blame] | 302 | SampleProfileSummaryBuilder Builder(ProfileSummaryBuilder::DefaultCutoffs); |
Easwaran Raman | 40ee23d | 2016-02-19 03:15:33 +0000 | [diff] [blame] | 303 | for (const auto &I : ProfileMap) { |
| 304 | const FunctionSamples &Profile = I.second; |
Easwaran Raman | e5a17e3 | 2016-05-19 21:07:12 +0000 | [diff] [blame] | 305 | Builder.addRecord(Profile); |
Easwaran Raman | 40ee23d | 2016-02-19 03:15:33 +0000 | [diff] [blame] | 306 | } |
Benjamin Kramer | 38de59e | 2016-05-20 09:18:37 +0000 | [diff] [blame] | 307 | Summary = Builder.getSummary(); |
Easwaran Raman | 40ee23d | 2016-02-19 03:15:33 +0000 | [diff] [blame] | 308 | } |