/// 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)
};
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 {
// 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");
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;
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;
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;
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++)
// 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);
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;