diff options
author | Xinliang David Li <davidxl@google.com> | 2015-12-14 18:44:01 +0000 |
---|---|---|
committer | Xinliang David Li <davidxl@google.com> | 2015-12-14 18:44:01 +0000 |
commit | e3bf4fd3943bffb5383d95376cb11e729c4b1669 (patch) | |
tree | 53a7b8c7755e28f348b58b89e7a2575b26ddc9d0 /llvm/lib/ProfileData/InstrProfWriter.cpp | |
parent | bbfc7219ef121d345784b0c080a268beb051c736 (diff) | |
download | bcm5719-llvm-e3bf4fd3943bffb5383d95376cb11e729c4b1669.tar.gz bcm5719-llvm-e3bf4fd3943bffb5383d95376cb11e729c4b1669.zip |
[PGO] Value profiling text format reader/writer support
This patch adds the missing functionality in parsable
text format support for value profiling.
Differential Revision: http://reviews.llvm.org/D15212
llvm-svn: 255523
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfWriter.cpp')
-rw-r--r-- | llvm/lib/ProfileData/InstrProfWriter.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp index 78bec012eeb..026912006b7 100644 --- a/llvm/lib/ProfileData/InstrProfWriter.cpp +++ b/llvm/lib/ProfileData/InstrProfWriter.cpp @@ -172,15 +172,47 @@ void InstrProfWriter::write(raw_fd_ostream &OS) { endian::Writer<little>(OS).write<uint64_t>(TableStart.second); } +static const char *ValueProfKindStr[] = { +#define VALUE_PROF_KIND(Enumerator, Value) #Enumerator, +#include "llvm/ProfileData/InstrProfData.inc" +}; + void InstrProfWriter::writeRecordInText(const InstrProfRecord &Func, raw_fd_ostream &OS) { OS << Func.Name << "\n"; OS << "# Func Hash:\n" << Func.Hash << "\n"; - OS << "# Num Counters:\n" <<Func.Counts.size() << "\n"; + OS << "# Num Counters:\n" << Func.Counts.size() << "\n"; OS << "# Counter Values:\n"; for (uint64_t Count : Func.Counts) OS << Count << "\n"; + uint32_t NumValueKinds = Func.getNumValueKinds(); + if (!NumValueKinds) { + OS << "\n"; + return; + } + + OS << "# Num Value Kinds:\n" << Func.getNumValueKinds() << "\n"; + for (uint32_t VK = 0; VK < IPVK_Last + 1; VK++) { + uint32_t NS = Func.getNumValueSites(VK); + if (!NS) + continue; + OS << "# ValueKind = " << ValueProfKindStr[VK] << ":\n" << VK << "\n"; + OS << "# NumValueSites:\n" << NS << "\n"; + for (uint32_t S = 0; S < NS; S++) { + uint32_t ND = Func.getNumValueDataForSite(VK, S); + OS << ND << "\n"; + std::unique_ptr<InstrProfValueData[]> VD = Func.getValueForSite(VK, S); + for (uint32_t I = 0; I < ND; I++) { + if (VK == IPVK_IndirectCallTarget) + OS << reinterpret_cast<const char *>(VD[I].Value) << ":" + << VD[I].Count << "\n"; + else + OS << VD[I].Value << ":" << VD[I].Count << "\n"; + } + } + } + OS << "\n"; } |