mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-20 19:04:10 -04:00
[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. For Maco-O platform, we generate the variable as linkonce_odr linkage as COMDAT is not supported. PGOInstrumenation now checks this bit to make sure it's an IR level instrumentation profile. The patch was submitted as r260164 but reverted due to a Darwin test breakage. Original Differential Revision: http://reviews.llvm.org/D15540 Differential Revision: http://reviews.llvm.org/D17020 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260385 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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()))
|
||||
|
||||
Reference in New Issue
Block a user