diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h --- a/llvm/include/llvm/ProfileData/InstrProf.h +++ b/llvm/include/llvm/ProfileData/InstrProf.h @@ -281,13 +281,20 @@ /// 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 --- a/llvm/include/llvm/ProfileData/InstrProfReader.h +++ b/llvm/include/llvm/ProfileData/InstrProfReader.h @@ -213,15 +213,16 @@ static bool hasFormat(const MemoryBuffer &Buffer); bool isIRLevelProfile() const override { - return static_cast(ProfileKind & InstrProfKind::IR); + return static_cast(ProfileKind & InstrProfKind::IRInstrumentation); } bool hasCSIRLevelProfile() const override { - return static_cast(ProfileKind & InstrProfKind::CS); + return static_cast(ProfileKind & InstrProfKind::ContextSensitive); } bool instrEntryBBEnabled() const override { - return static_cast(ProfileKind & InstrProfKind::BB); + return static_cast(ProfileKind & + InstrProfKind::FunctionEntryInstrumentation); } bool hasSingleByteCoverage() const override { diff --git a/llvm/include/llvm/ProfileData/InstrProfWriter.h b/llvm/include/llvm/ProfileData/InstrProfWriter.h --- a/llvm/include/llvm/ProfileData/InstrProfWriter.h +++ b/llvm/include/llvm/ProfileData/InstrProfWriter.h @@ -106,11 +106,13 @@ // Check if the profiles are in-compatible. Clang frontend profiles can't be // merged with other profile types. - if (static_cast((ProfileKind & InstrProfKind::FE) ^ - (Other & InstrProfKind::FE))) { + if (static_cast( + (ProfileKind & InstrProfKind::FrontendInstrumentation) ^ + (Other & InstrProfKind::FrontendInstrumentation))) { return make_error(instrprof_error::unsupported_version); } - if (testIncompatible(InstrProfKind::FunctionEntryOnly, InstrProfKind::BB)) { + if (testIncompatible(InstrProfKind::FunctionEntryOnly, + InstrProfKind::FunctionEntryInstrumentation)) { return make_error( 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 --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -45,13 +45,13 @@ 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 @@ 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 --- a/llvm/lib/ProfileData/InstrProfWriter.cpp +++ b/llvm/lib/ProfileData/InstrProfWriter.cpp @@ -336,11 +336,12 @@ IndexedInstrProf::Header Header; Header.Magic = IndexedInstrProf::Magic; Header.Version = IndexedInstrProf::ProfVersion::CurrentVersion; - if (static_cast(ProfileKind & InstrProfKind::IR)) + if (static_cast(ProfileKind & InstrProfKind::IRInstrumentation)) Header.Version |= VARIANT_MASK_IR_PROF; - if (static_cast(ProfileKind & InstrProfKind::CS)) + if (static_cast(ProfileKind & InstrProfKind::ContextSensitive)) Header.Version |= VARIANT_MASK_CSIR_PROF; - if (static_cast(ProfileKind & InstrProfKind::BB)) + if (static_cast(ProfileKind & + InstrProfKind::FunctionEntryInstrumentation)) Header.Version |= VARIANT_MASK_INSTR_ENTRY; if (static_cast(ProfileKind & InstrProfKind::SingleByteCoverage)) Header.Version |= VARIANT_MASK_BYTE_COVERAGE; @@ -381,7 +382,7 @@ OS.write(0); uint64_t CSSummaryOffset = 0; uint64_t CSSummarySize = 0; - if (static_cast(ProfileKind & InstrProfKind::CS)) { + if (static_cast(ProfileKind & InstrProfKind::ContextSensitive)) { CSSummaryOffset = OS.tell(); CSSummarySize = SummarySize / sizeof(uint64_t); for (unsigned I = 0; I < CSSummarySize; I++) @@ -438,7 +439,7 @@ // For Context Sensitive summary. std::unique_ptr TheCSSummary = nullptr; - if (static_cast(ProfileKind & InstrProfKind::CS)) { + if (static_cast(ProfileKind & InstrProfKind::ContextSensitive)) { TheCSSummary = IndexedInstrProf::allocSummary(SummarySize); std::unique_ptr CSPS = CSISB.getSummary(); setSummary(TheCSSummary.get(), *CSPS); @@ -553,12 +554,13 @@ Error InstrProfWriter::writeText(raw_fd_ostream &OS) { // Check CS first since it implies an IR level profile. - if (static_cast(ProfileKind & InstrProfKind::CS)) + if (static_cast(ProfileKind & InstrProfKind::ContextSensitive)) OS << "# CSIR level Instrumentation Flag\n:csir\n"; - else if (static_cast(ProfileKind & InstrProfKind::IR)) + else if (static_cast(ProfileKind & InstrProfKind::IRInstrumentation)) OS << "# IR level Instrumentation Flag\n:ir\n"; - if (static_cast(ProfileKind & InstrProfKind::BB)) + if (static_cast(ProfileKind & + InstrProfKind::FunctionEntryInstrumentation)) OS << "# Always instrument the function entry block\n:entry_first\n"; InstrProfSymtab Symtab;