[llvm] b681799 - [instrprof] Rename the profile kind types to be more descriptive.
Snehasish Kumar via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 23 13:16:00 PST 2022
Author: Snehasish Kumar
Date: 2022-02-23T13:15:56-08:00
New Revision: b6817999384e5ae125eb477c003c040d51770c96
URL: https://github.com/llvm/llvm-project/commit/b6817999384e5ae125eb477c003c040d51770c96
DIFF: https://github.com/llvm/llvm-project/commit/b6817999384e5ae125eb477c003c040d51770c96.diff
LOG: [instrprof] Rename the profile kind types to be more descriptive.
Based on the discussion in D115393, I've updated the names to be more
descriptive.
Reviewed By: ellis, MaskRay
Differential Revision: https://reviews.llvm.org/D120092
Added:
Modified:
llvm/include/llvm/ProfileData/InstrProf.h
llvm/include/llvm/ProfileData/InstrProfReader.h
llvm/include/llvm/ProfileData/InstrProfWriter.h
llvm/lib/ProfileData/InstrProfReader.cpp
llvm/lib/ProfileData/InstrProfWriter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index 9f7a6711131d..401d278cbd06 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -281,13 +281,20 @@ bool needsComdatForCounter(const Function &F, const Module &M);
/// An enum describing the attributes of an instrumented profile.
enum class InstrProfKind {
Unknown = 0x0,
- FE = 0x1, // A frontend clang profile, incompatible with other attrs.
- IR = 0x2, // An IR-level profile (default when -fprofile-generate is used).
- BB = 0x4, // A profile with entry basic block instrumentation.
- CS = 0x8, // A context sensitive IR-level profile.
- SingleByteCoverage = 0x10, // Use single byte probes for coverage.
- FunctionEntryOnly = 0x20, // Only instrument the function entry basic block.
- MemProf = 0x40, // A memory profile collected using -fprofile=memory.
+ // A frontend clang profile, incompatible with other attrs.
+ FrontendInstrumentation = 0x1,
+ // An IR-level profile (default when -fprofile-generate is used).
+ IRInstrumentation = 0x2,
+ // A profile with entry basic block instrumentation.
+ FunctionEntryInstrumentation = 0x4,
+ // A context sensitive IR-level profile.
+ ContextSensitive = 0x8,
+ // Use single byte probes for coverage.
+ SingleByteCoverage = 0x10,
+ // Only instrument the function entry basic block.
+ FunctionEntryOnly = 0x20,
+ // A memory profile collected using -fprofile=memory.
+ MemProf = 0x40,
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/MemProf)
};
diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h
index 7a18d5a6a11a..7a01ef5e2194 100644
--- a/llvm/include/llvm/ProfileData/InstrProfReader.h
+++ b/llvm/include/llvm/ProfileData/InstrProfReader.h
@@ -213,15 +213,16 @@ class TextInstrProfReader : public InstrProfReader {
static bool hasFormat(const MemoryBuffer &Buffer);
bool isIRLevelProfile() const override {
- return static_cast<bool>(ProfileKind & InstrProfKind::IR);
+ return static_cast<bool>(ProfileKind & InstrProfKind::IRInstrumentation);
}
bool hasCSIRLevelProfile() const override {
- return static_cast<bool>(ProfileKind & InstrProfKind::CS);
+ return static_cast<bool>(ProfileKind & InstrProfKind::ContextSensitive);
}
bool instrEntryBBEnabled() const override {
- return static_cast<bool>(ProfileKind & InstrProfKind::BB);
+ return static_cast<bool>(ProfileKind &
+ InstrProfKind::FunctionEntryInstrumentation);
}
bool hasSingleByteCoverage() const override {
diff --git a/llvm/include/llvm/ProfileData/InstrProfWriter.h b/llvm/include/llvm/ProfileData/InstrProfWriter.h
index bb180ac42c21..fb608269ad30 100644
--- a/llvm/include/llvm/ProfileData/InstrProfWriter.h
+++ b/llvm/include/llvm/ProfileData/InstrProfWriter.h
@@ -106,11 +106,13 @@ class InstrProfWriter {
// Check if the profiles are in-compatible. Clang frontend profiles can't be
// merged with other profile types.
- if (static_cast<bool>((ProfileKind & InstrProfKind::FE) ^
- (Other & InstrProfKind::FE))) {
+ if (static_cast<bool>(
+ (ProfileKind & InstrProfKind::FrontendInstrumentation) ^
+ (Other & InstrProfKind::FrontendInstrumentation))) {
return make_error<InstrProfError>(instrprof_error::unsupported_version);
}
- if (testIncompatible(InstrProfKind::FunctionEntryOnly, InstrProfKind::BB)) {
+ if (testIncompatible(InstrProfKind::FunctionEntryOnly,
+ InstrProfKind::FunctionEntryInstrumentation)) {
return make_error<InstrProfError>(
instrprof_error::unsupported_version,
"cannot merge FunctionEntryOnly profiles and BB profiles together");
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index f79169c7190f..67f61589633e 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -45,13 +45,13 @@ using namespace llvm;
static InstrProfKind getProfileKindFromVersion(uint64_t Version) {
InstrProfKind ProfileKind = InstrProfKind::Unknown;
if (Version & VARIANT_MASK_IR_PROF) {
- ProfileKind |= InstrProfKind::IR;
+ ProfileKind |= InstrProfKind::IRInstrumentation;
}
if (Version & VARIANT_MASK_CSIR_PROF) {
- ProfileKind |= InstrProfKind::CS;
+ ProfileKind |= InstrProfKind::ContextSensitive;
}
if (Version & VARIANT_MASK_INSTR_ENTRY) {
- ProfileKind |= InstrProfKind::BB;
+ ProfileKind |= InstrProfKind::FunctionEntryInstrumentation;
}
if (Version & VARIANT_MASK_BYTE_COVERAGE) {
ProfileKind |= InstrProfKind::SingleByteCoverage;
@@ -177,16 +177,16 @@ Error TextInstrProfReader::readHeader() {
while (Line->startswith(":")) {
StringRef Str = Line->substr(1);
if (Str.equals_insensitive("ir"))
- ProfileKind |= InstrProfKind::IR;
+ ProfileKind |= InstrProfKind::IRInstrumentation;
else if (Str.equals_insensitive("fe"))
- ProfileKind |= InstrProfKind::FE;
+ ProfileKind |= InstrProfKind::FrontendInstrumentation;
else if (Str.equals_insensitive("csir")) {
- ProfileKind |= InstrProfKind::IR;
- ProfileKind |= InstrProfKind::CS;
+ ProfileKind |= InstrProfKind::IRInstrumentation;
+ ProfileKind |= InstrProfKind::ContextSensitive;
} else if (Str.equals_insensitive("entry_first"))
- ProfileKind |= InstrProfKind::BB;
+ ProfileKind |= InstrProfKind::FunctionEntryInstrumentation;
else if (Str.equals_insensitive("not_entry_first"))
- ProfileKind &= ~InstrProfKind::BB;
+ ProfileKind &= ~InstrProfKind::FunctionEntryInstrumentation;
else
return error(instrprof_error::bad_header);
++Line;
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 4c974f402d2b..2771b3a3eff1 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -336,11 +336,12 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
IndexedInstrProf::Header Header;
Header.Magic = IndexedInstrProf::Magic;
Header.Version = IndexedInstrProf::ProfVersion::CurrentVersion;
- if (static_cast<bool>(ProfileKind & InstrProfKind::IR))
+ if (static_cast<bool>(ProfileKind & InstrProfKind::IRInstrumentation))
Header.Version |= VARIANT_MASK_IR_PROF;
- if (static_cast<bool>(ProfileKind & InstrProfKind::CS))
+ if (static_cast<bool>(ProfileKind & InstrProfKind::ContextSensitive))
Header.Version |= VARIANT_MASK_CSIR_PROF;
- if (static_cast<bool>(ProfileKind & InstrProfKind::BB))
+ if (static_cast<bool>(ProfileKind &
+ InstrProfKind::FunctionEntryInstrumentation))
Header.Version |= VARIANT_MASK_INSTR_ENTRY;
if (static_cast<bool>(ProfileKind & InstrProfKind::SingleByteCoverage))
Header.Version |= VARIANT_MASK_BYTE_COVERAGE;
@@ -381,7 +382,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
OS.write(0);
uint64_t CSSummaryOffset = 0;
uint64_t CSSummarySize = 0;
- if (static_cast<bool>(ProfileKind & InstrProfKind::CS)) {
+ if (static_cast<bool>(ProfileKind & InstrProfKind::ContextSensitive)) {
CSSummaryOffset = OS.tell();
CSSummarySize = SummarySize / sizeof(uint64_t);
for (unsigned I = 0; I < CSSummarySize; I++)
@@ -438,7 +439,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
// For Context Sensitive summary.
std::unique_ptr<IndexedInstrProf::Summary> TheCSSummary = nullptr;
- if (static_cast<bool>(ProfileKind & InstrProfKind::CS)) {
+ if (static_cast<bool>(ProfileKind & InstrProfKind::ContextSensitive)) {
TheCSSummary = IndexedInstrProf::allocSummary(SummarySize);
std::unique_ptr<ProfileSummary> CSPS = CSISB.getSummary();
setSummary(TheCSSummary.get(), *CSPS);
@@ -553,12 +554,13 @@ void InstrProfWriter::writeRecordInText(StringRef Name, uint64_t Hash,
Error InstrProfWriter::writeText(raw_fd_ostream &OS) {
// Check CS first since it implies an IR level profile.
- if (static_cast<bool>(ProfileKind & InstrProfKind::CS))
+ if (static_cast<bool>(ProfileKind & InstrProfKind::ContextSensitive))
OS << "# CSIR level Instrumentation Flag\n:csir\n";
- else if (static_cast<bool>(ProfileKind & InstrProfKind::IR))
+ else if (static_cast<bool>(ProfileKind & InstrProfKind::IRInstrumentation))
OS << "# IR level Instrumentation Flag\n:ir\n";
- if (static_cast<bool>(ProfileKind & InstrProfKind::BB))
+ if (static_cast<bool>(ProfileKind &
+ InstrProfKind::FunctionEntryInstrumentation))
OS << "# Always instrument the function entry block\n:entry_first\n";
InstrProfSymtab Symtab;
More information about the llvm-commits
mailing list