[PGO] Profile summary reader/writer support
With this patch, the profile summary data will be available in indexed
profile data file so that profiler reader/compiler optimizer can start
to make use of.
Differential Revision: http://reviews.llvm.org/D16258
llvm-svn: 259626
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 0ccc162..a06a437 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -641,4 +641,19 @@
}
}
+ProfileSummary::ProfileSummary(const IndexedInstrProf::Summary &S)
+ : TotalCount(S.get(IndexedInstrProf::Summary::TotalBlockCount)),
+ MaxBlockCount(S.get(IndexedInstrProf::Summary::MaxBlockCount)),
+ MaxInternalBlockCount(
+ S.get(IndexedInstrProf::Summary::MaxInternalBlockCount)),
+ MaxFunctionCount(S.get(IndexedInstrProf::Summary::MaxFunctionCount)),
+ NumBlocks(S.get(IndexedInstrProf::Summary::TotalNumBlocks)),
+ NumFunctions(S.get(IndexedInstrProf::Summary::TotalNumFunctions)) {
+ for (unsigned I = 0; I < S.NumCutoffEntries; I++) {
+ const IndexedInstrProf::Summary::Entry &Ent = S.getEntry(I);
+ DetailedSummary.emplace_back((uint32_t)Ent.Cutoff, Ent.MinBlockCount,
+ Ent.NumBlocks);
+ }
+}
+
} // end namespace llvm