diff options
author | Rong Xu <xur@google.com> | 2016-02-08 21:07:46 +0000 |
---|---|---|
committer | Rong Xu <xur@google.com> | 2016-02-08 21:07:46 +0000 |
commit | 1288a19421232137ed288e4b9ba202f3b37b2006 (patch) | |
tree | a5c81a0b9a6c6f2ff258444f914e829610b6f3ab /llvm/lib/ProfileData/InstrProfWriter.cpp | |
parent | 264d7e5b685a739f52e680089ba92f0129708687 (diff) | |
download | llvm-1288a19421232137ed288e4b9ba202f3b37b2006.zip llvm-1288a19421232137ed288e4b9ba202f3b37b2006.tar.gz llvm-1288a19421232137ed288e4b9ba202f3b37b2006.tar.bz2 |
[PGO] Differentiate Clang instrumentation and IR level instrumentation profiles
This patch uses one bit in profile version to differentiate Clang
instrumentation and IR level instrumentation profiles.
PGOInstrumenation generates a COMDAT variable __llvm_profile_raw_version so
that the compiler runtime can set the right profile kind.
PGOInstrumenation now checks this bit to make sure it's an IR level
instrumentation profile.
Differential Revision: http://reviews.llvm.org/D15540
llvm-svn: 260146
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfWriter.cpp')
-rw-r--r-- | llvm/lib/ProfileData/InstrProfWriter.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp index a486d4e..3e32571 100644 --- a/llvm/lib/ProfileData/InstrProfWriter.cpp +++ b/llvm/lib/ProfileData/InstrProfWriter.cpp @@ -142,7 +142,7 @@ public: } InstrProfWriter::InstrProfWriter(bool Sparse) - : Sparse(Sparse), FunctionData(), + : Sparse(Sparse), FunctionData(), ProfileKind(PF_Unknown), InfoObj(new InstrProfRecordWriterTrait()) {} InstrProfWriter::~InstrProfWriter() { delete InfoObj; } @@ -230,6 +230,8 @@ void InstrProfWriter::writeImpl(ProfOStream &OS) { IndexedInstrProf::Header Header; Header.Magic = IndexedInstrProf::Magic; Header.Version = IndexedInstrProf::ProfVersion::CurrentVersion; + if (ProfileKind == PF_IRLevel) + Header.Version |= VARIANT_MASK_IR_PROF; Header.Unused = 0; Header.HashType = static_cast<uint64_t>(IndexedInstrProf::HashType); Header.HashOffset = 0; @@ -336,6 +338,8 @@ void InstrProfWriter::writeRecordInText(const InstrProfRecord &Func, } void InstrProfWriter::writeText(raw_fd_ostream &OS) { + if (ProfileKind == PF_IRLevel) + OS << "# IR level Instrumentation Flag\n:ir\n"; InstrProfSymtab Symtab; for (const auto &I : FunctionData) if (shouldEncodeData(I.getValue())) |