Move ProfileSummary to IR.
This splits ProfileSummary into two classes: a ProfileSummary class that has methods to convert from/to metadata and a ProfileSummaryBuilder class that computes the profiles summary which is in ProfileData.
Differential Revision: http://reviews.llvm.org/D20314
llvm-svn: 270136
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index d45e6af..1b042be 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -281,7 +281,7 @@
if (ShowDetailedSummary && DetailedSummaryCutoffs.empty()) {
Cutoffs = {800000, 900000, 950000, 990000, 999000, 999900, 999990};
}
- InstrProfSummary PS(Cutoffs);
+ InstrProfSummaryBuilder Builder(Cutoffs);
if (Error E = ReaderOrErr.takeError())
exitWithError(std::move(E), Filename);
@@ -302,7 +302,7 @@
}
assert(Func.Counts.size() > 0 && "function missing entry counter");
- PS.addRecord(Func);
+ Builder.addRecord(Func);
if (Show) {
@@ -353,18 +353,19 @@
if (ShowCounts && TextFormat)
return 0;
-
+ std::unique_ptr<InstrProfSummary> PS(Builder.getSummary());
if (ShowAllFunctions || !ShowFunction.empty())
OS << "Functions shown: " << ShownFunctions << "\n";
- OS << "Total functions: " << PS.getNumFunctions() << "\n";
- OS << "Maximum function count: " << PS.getMaxFunctionCount() << "\n";
- OS << "Maximum internal block count: " << PS.getMaxInternalBlockCount() << "\n";
+ OS << "Total functions: " << PS->getNumFunctions() << "\n";
+ OS << "Maximum function count: " << PS->getMaxFunctionCount() << "\n";
+ OS << "Maximum internal block count: " << PS->getMaxInternalBlockCount()
+ << "\n";
if (ShowDetailedSummary) {
OS << "Detailed summary:\n";
- OS << "Total number of blocks: " << PS.getNumBlocks() << "\n";
- OS << "Total count: " << PS.getTotalCount() << "\n";
- for (auto Entry : PS.getDetailedSummary()) {
+ OS << "Total number of blocks: " << PS->getNumBlocks() << "\n";
+ OS << "Total count: " << PS->getTotalCount() << "\n";
+ for (auto Entry : PS->getDetailedSummary()) {
OS << Entry.NumCounts << " blocks with count >= " << Entry.MinCount
<< " account for "
<< format("%0.6g", (float)Entry.Cutoff / ProfileSummary::Scale * 100)