diff options
author | ronryvchin <94285266+ronryvchin@users.noreply.github.com> | 2024-12-04 08:56:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-04 07:56:46 +0100 |
commit | ff281f7d37ead15bdbdbfccb4b82ea93013b1a00 (patch) | |
tree | 6e2845fbe9fd9ae58443e17a3376ae922268f730 /llvm/lib/ProfileData/InstrProfWriter.cpp | |
parent | 92ed7e292443de1d89754a59a533ded160d544eb (diff) | |
download | llvm-ff281f7d37ead15bdbdbfccb4b82ea93013b1a00.zip llvm-ff281f7d37ead15bdbdbfccb4b82ea93013b1a00.tar.gz llvm-ff281f7d37ead15bdbdbfccb4b82ea93013b1a00.tar.bz2 |
[PGO] Add option to always instrumenting loop entries (#116789)
This patch extends the PGO infrastructure with an option to prefer the
instrumentation of loop entry blocks.
This option is a generalization of
https://github.com/llvm/llvm-project/commit/19fb5b467bb97f95eace1f3637d2d1041cebd3ce,
and helps to cover cases where the loop exit is never executed.
An example where this can occur are event handling loops.
Note that change does NOT change the default behavior.
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfWriter.cpp')
-rw-r--r-- | llvm/lib/ProfileData/InstrProfWriter.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp index d8ab18d..64625de 100644 --- a/llvm/lib/ProfileData/InstrProfWriter.cpp +++ b/llvm/lib/ProfileData/InstrProfWriter.cpp @@ -877,6 +877,9 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) { if (static_cast<bool>(ProfileKind & InstrProfKind::FunctionEntryInstrumentation)) Header.Version |= VARIANT_MASK_INSTR_ENTRY; + if (static_cast<bool>(ProfileKind & + InstrProfKind::LoopEntriesInstrumentation)) + Header.Version |= VARIANT_MASK_INSTR_LOOP_ENTRIES; if (static_cast<bool>(ProfileKind & InstrProfKind::SingleByteCoverage)) Header.Version |= VARIANT_MASK_BYTE_COVERAGE; if (static_cast<bool>(ProfileKind & InstrProfKind::FunctionEntryOnly)) @@ -1120,6 +1123,10 @@ Error InstrProfWriter::writeText(raw_fd_ostream &OS) { if (static_cast<bool>(ProfileKind & InstrProfKind::FunctionEntryInstrumentation)) OS << "# Always instrument the function entry block\n:entry_first\n"; + if (static_cast<bool>(ProfileKind & + InstrProfKind::LoopEntriesInstrumentation)) + OS << "# Always instrument the loop entry " + "blocks\n:instrument_loop_entries\n"; if (static_cast<bool>(ProfileKind & InstrProfKind::SingleByteCoverage)) OS << "# Instrument block coverage\n:single_byte_coverage\n"; InstrProfSymtab Symtab; |