From 0b37180c6fc005f12c26ca7e42ee709bbeada9e9 Mon Sep 17 00:00:00 2001 From: Maksim Panchenko Date: Tue, 10 Jul 2018 10:25:55 -0700 Subject: [PATCH] [perf2bolt] Accept `-` as a valid misprediction symbol Summary: As reported in GH-28 `perf` can produce `-` symbol for misprediction bit if the bit is not supported by the kernel/HW. In this case we can ignore the bit. (cherry picked from commit 0a4ad831e49388ccc49ae15ecdb51c58b6eaafff) --- bolt/src/DataAggregator.cpp | 8 +++++++- bolt/src/DataReader.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bolt/src/DataAggregator.cpp b/bolt/src/DataAggregator.cpp index c94be6f0b59b..8b3ee0bd56af 100644 --- a/bolt/src/DataAggregator.cpp +++ b/bolt/src/DataAggregator.cpp @@ -653,13 +653,19 @@ ErrorOr DataAggregator::parseLBREntry() { return EC; StringRef MispredStr = MispredStrRes.get(); if (MispredStr.size() != 1 || - (MispredStr[0] != 'P' && MispredStr[0] != 'M')) { + (MispredStr[0] != 'P' && MispredStr[0] != 'M' && MispredStr[0] != '-')) { reportError("expected single char for mispred bit"); Diag << "Found: " << MispredStr << "\n"; return make_error_code(llvm::errc::io_error); } Res.Mispred = MispredStr[0] == 'M'; + static bool MispredWarning = true;; + if (MispredStr[0] == '-' && MispredWarning) { + errs() << "PERF2BOLT-WARNING: misprediction bit is missing in profile\n"; + MispredWarning = false; + } + auto Rest = parseString(FieldSeparator, true); if (std::error_code EC = Rest.getError()) return EC; diff --git a/bolt/src/DataReader.cpp b/bolt/src/DataReader.cpp index 348b83d4e334..62e7be78b8a9 100644 --- a/bolt/src/DataReader.cpp +++ b/bolt/src/DataReader.cpp @@ -268,7 +268,7 @@ DataReader::readPerfData(StringRef Path, raw_ostream &Diag) { } void DataReader::reportError(StringRef ErrorMsg) { - Diag << "Error reading bolt data input file: line " << Line << ", column " + Diag << "Error reading BOLT data input file: line " << Line << ", column " << Col << ": " << ErrorMsg << '\n'; }