Skip to content

Commit b681799

Browse files
author
Snehasish Kumar
committed
[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
1 parent 9392c0d commit b681799

File tree

5 files changed

+42
-30
lines changed

5 files changed

+42
-30
lines changed

llvm/include/llvm/ProfileData/InstrProf.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,20 @@ bool needsComdatForCounter(const Function &F, const Module &M);
281281
/// An enum describing the attributes of an instrumented profile.
282282
enum class InstrProfKind {
283283
Unknown = 0x0,
284-
FE = 0x1, // A frontend clang profile, incompatible with other attrs.
285-
IR = 0x2, // An IR-level profile (default when -fprofile-generate is used).
286-
BB = 0x4, // A profile with entry basic block instrumentation.
287-
CS = 0x8, // A context sensitive IR-level profile.
288-
SingleByteCoverage = 0x10, // Use single byte probes for coverage.
289-
FunctionEntryOnly = 0x20, // Only instrument the function entry basic block.
290-
MemProf = 0x40, // A memory profile collected using -fprofile=memory.
284+
// A frontend clang profile, incompatible with other attrs.
285+
FrontendInstrumentation = 0x1,
286+
// An IR-level profile (default when -fprofile-generate is used).
287+
IRInstrumentation = 0x2,
288+
// A profile with entry basic block instrumentation.
289+
FunctionEntryInstrumentation = 0x4,
290+
// A context sensitive IR-level profile.
291+
ContextSensitive = 0x8,
292+
// Use single byte probes for coverage.
293+
SingleByteCoverage = 0x10,
294+
// Only instrument the function entry basic block.
295+
FunctionEntryOnly = 0x20,
296+
// A memory profile collected using -fprofile=memory.
297+
MemProf = 0x40,
291298
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/MemProf)
292299
};
293300

llvm/include/llvm/ProfileData/InstrProfReader.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,16 @@ class TextInstrProfReader : public InstrProfReader {
213213
static bool hasFormat(const MemoryBuffer &Buffer);
214214

215215
bool isIRLevelProfile() const override {
216-
return static_cast<bool>(ProfileKind & InstrProfKind::IR);
216+
return static_cast<bool>(ProfileKind & InstrProfKind::IRInstrumentation);
217217
}
218218

219219
bool hasCSIRLevelProfile() const override {
220-
return static_cast<bool>(ProfileKind & InstrProfKind::CS);
220+
return static_cast<bool>(ProfileKind & InstrProfKind::ContextSensitive);
221221
}
222222

223223
bool instrEntryBBEnabled() const override {
224-
return static_cast<bool>(ProfileKind & InstrProfKind::BB);
224+
return static_cast<bool>(ProfileKind &
225+
InstrProfKind::FunctionEntryInstrumentation);
225226
}
226227

227228
bool hasSingleByteCoverage() const override {

llvm/include/llvm/ProfileData/InstrProfWriter.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@ class InstrProfWriter {
106106

107107
// Check if the profiles are in-compatible. Clang frontend profiles can't be
108108
// merged with other profile types.
109-
if (static_cast<bool>((ProfileKind & InstrProfKind::FE) ^
110-
(Other & InstrProfKind::FE))) {
109+
if (static_cast<bool>(
110+
(ProfileKind & InstrProfKind::FrontendInstrumentation) ^
111+
(Other & InstrProfKind::FrontendInstrumentation))) {
111112
return make_error<InstrProfError>(instrprof_error::unsupported_version);
112113
}
113-
if (testIncompatible(InstrProfKind::FunctionEntryOnly, InstrProfKind::BB)) {
114+
if (testIncompatible(InstrProfKind::FunctionEntryOnly,
115+
InstrProfKind::FunctionEntryInstrumentation)) {
114116
return make_error<InstrProfError>(
115117
instrprof_error::unsupported_version,
116118
"cannot merge FunctionEntryOnly profiles and BB profiles together");

llvm/lib/ProfileData/InstrProfReader.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ using namespace llvm;
4545
static InstrProfKind getProfileKindFromVersion(uint64_t Version) {
4646
InstrProfKind ProfileKind = InstrProfKind::Unknown;
4747
if (Version & VARIANT_MASK_IR_PROF) {
48-
ProfileKind |= InstrProfKind::IR;
48+
ProfileKind |= InstrProfKind::IRInstrumentation;
4949
}
5050
if (Version & VARIANT_MASK_CSIR_PROF) {
51-
ProfileKind |= InstrProfKind::CS;
51+
ProfileKind |= InstrProfKind::ContextSensitive;
5252
}
5353
if (Version & VARIANT_MASK_INSTR_ENTRY) {
54-
ProfileKind |= InstrProfKind::BB;
54+
ProfileKind |= InstrProfKind::FunctionEntryInstrumentation;
5555
}
5656
if (Version & VARIANT_MASK_BYTE_COVERAGE) {
5757
ProfileKind |= InstrProfKind::SingleByteCoverage;
@@ -177,16 +177,16 @@ Error TextInstrProfReader::readHeader() {
177177
while (Line->startswith(":")) {
178178
StringRef Str = Line->substr(1);
179179
if (Str.equals_insensitive("ir"))
180-
ProfileKind |= InstrProfKind::IR;
180+
ProfileKind |= InstrProfKind::IRInstrumentation;
181181
else if (Str.equals_insensitive("fe"))
182-
ProfileKind |= InstrProfKind::FE;
182+
ProfileKind |= InstrProfKind::FrontendInstrumentation;
183183
else if (Str.equals_insensitive("csir")) {
184-
ProfileKind |= InstrProfKind::IR;
185-
ProfileKind |= InstrProfKind::CS;
184+
ProfileKind |= InstrProfKind::IRInstrumentation;
185+
ProfileKind |= InstrProfKind::ContextSensitive;
186186
} else if (Str.equals_insensitive("entry_first"))
187-
ProfileKind |= InstrProfKind::BB;
187+
ProfileKind |= InstrProfKind::FunctionEntryInstrumentation;
188188
else if (Str.equals_insensitive("not_entry_first"))
189-
ProfileKind &= ~InstrProfKind::BB;
189+
ProfileKind &= ~InstrProfKind::FunctionEntryInstrumentation;
190190
else
191191
return error(instrprof_error::bad_header);
192192
++Line;

llvm/lib/ProfileData/InstrProfWriter.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,12 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
336336
IndexedInstrProf::Header Header;
337337
Header.Magic = IndexedInstrProf::Magic;
338338
Header.Version = IndexedInstrProf::ProfVersion::CurrentVersion;
339-
if (static_cast<bool>(ProfileKind & InstrProfKind::IR))
339+
if (static_cast<bool>(ProfileKind & InstrProfKind::IRInstrumentation))
340340
Header.Version |= VARIANT_MASK_IR_PROF;
341-
if (static_cast<bool>(ProfileKind & InstrProfKind::CS))
341+
if (static_cast<bool>(ProfileKind & InstrProfKind::ContextSensitive))
342342
Header.Version |= VARIANT_MASK_CSIR_PROF;
343-
if (static_cast<bool>(ProfileKind & InstrProfKind::BB))
343+
if (static_cast<bool>(ProfileKind &
344+
InstrProfKind::FunctionEntryInstrumentation))
344345
Header.Version |= VARIANT_MASK_INSTR_ENTRY;
345346
if (static_cast<bool>(ProfileKind & InstrProfKind::SingleByteCoverage))
346347
Header.Version |= VARIANT_MASK_BYTE_COVERAGE;
@@ -381,7 +382,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
381382
OS.write(0);
382383
uint64_t CSSummaryOffset = 0;
383384
uint64_t CSSummarySize = 0;
384-
if (static_cast<bool>(ProfileKind & InstrProfKind::CS)) {
385+
if (static_cast<bool>(ProfileKind & InstrProfKind::ContextSensitive)) {
385386
CSSummaryOffset = OS.tell();
386387
CSSummarySize = SummarySize / sizeof(uint64_t);
387388
for (unsigned I = 0; I < CSSummarySize; I++)
@@ -438,7 +439,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
438439

439440
// For Context Sensitive summary.
440441
std::unique_ptr<IndexedInstrProf::Summary> TheCSSummary = nullptr;
441-
if (static_cast<bool>(ProfileKind & InstrProfKind::CS)) {
442+
if (static_cast<bool>(ProfileKind & InstrProfKind::ContextSensitive)) {
442443
TheCSSummary = IndexedInstrProf::allocSummary(SummarySize);
443444
std::unique_ptr<ProfileSummary> CSPS = CSISB.getSummary();
444445
setSummary(TheCSSummary.get(), *CSPS);
@@ -553,12 +554,13 @@ void InstrProfWriter::writeRecordInText(StringRef Name, uint64_t Hash,
553554

554555
Error InstrProfWriter::writeText(raw_fd_ostream &OS) {
555556
// Check CS first since it implies an IR level profile.
556-
if (static_cast<bool>(ProfileKind & InstrProfKind::CS))
557+
if (static_cast<bool>(ProfileKind & InstrProfKind::ContextSensitive))
557558
OS << "# CSIR level Instrumentation Flag\n:csir\n";
558-
else if (static_cast<bool>(ProfileKind & InstrProfKind::IR))
559+
else if (static_cast<bool>(ProfileKind & InstrProfKind::IRInstrumentation))
559560
OS << "# IR level Instrumentation Flag\n:ir\n";
560561

561-
if (static_cast<bool>(ProfileKind & InstrProfKind::BB))
562+
if (static_cast<bool>(ProfileKind &
563+
InstrProfKind::FunctionEntryInstrumentation))
562564
OS << "# Always instrument the function entry block\n:entry_first\n";
563565
InstrProfSymtab Symtab;
564566

0 commit comments

Comments
 (0)