diff --git a/bolt/BinaryFunction.h b/bolt/BinaryFunction.h index 435ebd56b153..fc6532c5bb48 100644 --- a/bolt/BinaryFunction.h +++ b/bolt/BinaryFunction.h @@ -1496,34 +1496,18 @@ public: } /// Mark this function as having a valid profile. - void markProfiled() { + void markProfiled(uint16_t Flags) { if (ExecutionCount == COUNT_NO_PROFILE) ExecutionCount = 0; + ProfileFlags = Flags; ProfileMatchRatio = 1.0f; } - /// Check if the function profile used LBR. - bool hasLBRProfile() const { - return ProfileFlags & PF_LBR; - } - - /// Set status of the function profile. - void setHasLBRProfile(bool Value) { - assert(!(ProfileFlags & PF_SAMPLE) && - "cannot combine LBR and samples profile"); - ProfileFlags |= PF_LBR; - } - /// Return flags describing a profile for this function. uint16_t getProfileFlags() const { return ProfileFlags; } - /// Set profile flags for the function to \p Flags. - void setProfileFlags(uint16_t Flags) { - ProfileFlags = Flags; - } - void addCFIInstruction(uint64_t Offset, MCCFIInstruction &&Inst) { assert(!Instructions.empty()); diff --git a/bolt/BinaryFunctionProfile.cpp b/bolt/BinaryFunctionProfile.cpp index 3f417be0f9cc..ebc7e280fdd6 100644 --- a/bolt/BinaryFunctionProfile.cpp +++ b/bolt/BinaryFunctionProfile.cpp @@ -306,7 +306,7 @@ void BinaryFunction::postProcessProfile() { return; } - if (!hasLBRProfile()) + if (!(getProfileFlags() & PF_LBR)) return; // Pre-sort branch data. diff --git a/bolt/DataAggregator.cpp b/bolt/DataAggregator.cpp index f09a339ed9df..b63a1cf08091 100644 --- a/bolt/DataAggregator.cpp +++ b/bolt/DataAggregator.cpp @@ -419,12 +419,13 @@ bool DataAggregator::aggregate(BinaryContext &BC, for (auto &BFI : BFs) { auto &BF = BFI.second; if (BF.getBranchData()) { - BF.markProfiled(); + const auto Flags = opts::BasicAggregation ? BinaryFunction::PF_SAMPLE + : BinaryFunction::PF_LBR; + BF.markProfiled(Flags); } } auto PI3 = sys::Wait(MemEventsPI, 0, true, &Error); - if (PI3.ReturnCode != 0) { ErrorOr> MB = MemoryBuffer::getFileOrSTDIN(PerfMemEventsErrPath.data()); @@ -455,8 +456,9 @@ bool DataAggregator::aggregate(BinaryContext &BC, ParsingBuf = FileBuf->getBuffer(); Col = 0; Line = 1; - if (parseMemEvents()) { - outs() << "PERF2BOLT: Failed to parse memory events\n"; + if (const auto EC = parseMemEvents()) { + errs() << "PERF2BOLT: Failed to parse memory events: " + << EC.message() << '\n'; } deleteTempFiles(); diff --git a/bolt/ProfileReader.cpp b/bolt/ProfileReader.cpp index ebac57abda38..5e2ad7986b91 100644 --- a/bolt/ProfileReader.cpp +++ b/bolt/ProfileReader.cpp @@ -55,8 +55,6 @@ ProfileReader::parseFunctionProfile(BinaryFunction &BF, uint64_t MismatchedCalls = 0; uint64_t MismatchedEdges = 0; - BF.setProfileFlags(YamlBP.Header.Flags); - uint64_t FunctionExecutionCount = 0; BF.setExecutionCount(YamlBF.ExecCount); @@ -206,7 +204,7 @@ ProfileReader::parseFunctionProfile(BinaryFunction &BF, ProfileMatched &= !MismatchedBlocks && !MismatchedCalls && !MismatchedEdges; if (ProfileMatched) - BF.markProfiled(); + BF.markProfiled(YamlBP.Header.Flags); if (!ProfileMatched && opts::Verbosity >= 1) { errs() << "BOLT-WARNING: " << MismatchedBlocks << " blocks, " diff --git a/bolt/ProfileWriter.cpp b/bolt/ProfileWriter.cpp index e92544513788..fa0a7a4cb62c 100644 --- a/bolt/ProfileWriter.cpp +++ b/bolt/ProfileWriter.cpp @@ -32,7 +32,7 @@ void convert(const BinaryFunction &BF, yaml::bolt::BinaryFunctionProfile &YamlBF) { auto &BC = BF.getBinaryContext(); - const auto LBRProfile = BF.hasLBRProfile(); + const auto LBRProfile = BF.getProfileFlags() & BinaryFunction::PF_LBR; YamlBF.Name = BF.getPrintName(); YamlBF.Id = BF.getFunctionNumber();