[llvm] [Bolt] Add a new hidden option to perf2bolt for testing purpose (PR #163785)
Paschalis Mpeis via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 7 05:16:36 PST 2025
================
@@ -372,6 +379,80 @@ void DataAggregator::parsePreAggregated() {
}
}
+bool DataAggregator::isMMapEvent(StringRef Line) {
+ // Short cut to avoid string find is possible.
+ if (Line.empty() || Line.size() < 50)
+ return false;
+
+ // Check that PERF_RECORD_MMAP2 or PERF_RECORD_MMAP appear in the line.
+ return Line.contains("PERF_RECORD_MMAP");
+}
+
+void DataAggregator::parsePerfScriptEvents() {
+ outs() << "PERF2BOLT: parsing a hybrid perf-script events...\n";
+ NamedRegionTimer T("parsePerfScriptEvents", "Parsing perf-script events",
+ TimerGroupName, TimerGroupDesc, opts::TimeAggregator);
+
+ ErrorOr<std::unique_ptr<MemoryBuffer>> MB =
+ MemoryBuffer::getFileOrSTDIN(Filename);
+ if (std::error_code EC = MB.getError()) {
+ errs() << "PERF2BOLT-ERROR: cannot open " << Filename << ": "
+ << EC.message() << "\n";
+ exit(1);
+ }
+
+ FileBuf = std::move(*MB);
+ ParsingBuf = FileBuf->getBuffer();
+ Col = 0;
+ Line = 1;
+ std::string MMapEvents = "";
+ std::string BranchEvents = "";
----------------
paschalis-mpeis wrote:
> Side note: Using parseMMapEvents directly on the parsing buffer works correctly, the mmap function is able to handle other events like brstack. However if parseBranchEvents finds an mmap event, it will report an error.
Maybe we could teach `parseBranchEvents` to ignore mmaps when we have this perf-script option used?
https://github.com/llvm/llvm-project/pull/163785
More information about the llvm-commits
mailing list