@@ -95,12 +95,6 @@ cl::opt<bool> ReadPreAggregated(
9595 " pa" , cl::desc(" skip perf and read data from a pre-aggregated file format" ),
9696 cl::cat(AggregatorCategory));
9797
98- cl::opt<std::string>
99- ReadPerfEvents (" perf-script-events" ,
100- cl::desc (" skip perf event collection by supplying a "
101- " perf-script output in a textual format" ),
102- cl::ReallyHidden, cl::init(" " ), cl::cat(AggregatorCategory));
103-
10498static cl::opt<bool >
10599TimeAggregator (" time-aggr" ,
106100 cl::desc (" time BOLT aggregator" ),
@@ -173,9 +167,8 @@ void DataAggregator::findPerfExecutable() {
173167void DataAggregator::start () {
174168 outs () << " PERF2BOLT: Starting data aggregation job for " << Filename << " \n " ;
175169
176- // Don't launch perf for pre-aggregated files or when perf input is specified
177- // by the user.
178- if (opts::ReadPreAggregated || !opts::ReadPerfEvents.empty ())
170+ // Don't launch perf for pre-aggregated files
171+ if (opts::ReadPreAggregated)
179172 return ;
180173
181174 findPerfExecutable ();
@@ -471,13 +464,6 @@ void DataAggregator::filterBinaryMMapInfo() {
471464
472465int DataAggregator::prepareToParse (StringRef Name, PerfProcessInfo &Process,
473466 PerfProcessErrorCallbackTy Callback) {
474- if (!opts::ReadPerfEvents.empty ()) {
475- outs () << " PERF2BOLT: using pre-processed perf events for '" << Name
476- << " ' (perf-script-events)\n " ;
477- ParsingBuf = opts::ReadPerfEvents;
478- return 0 ;
479- }
480-
481467 std::string Error;
482468 outs () << " PERF2BOLT: waiting for perf " << Name
483469 << " collection to finish...\n " ;
@@ -2070,6 +2056,15 @@ std::error_code DataAggregator::parseMMapEvents() {
20702056 if (FileMMapInfo.first == " (deleted)" )
20712057 continue ;
20722058
2059+ // Consider only the first mapping of the file for any given PID
2060+ auto Range = GlobalMMapInfo.equal_range (FileMMapInfo.first );
2061+ bool PIDExists = llvm::any_of (make_range (Range), [&](const auto &MI) {
2062+ return MI.second .PID == FileMMapInfo.second .PID ;
2063+ });
2064+
2065+ if (PIDExists)
2066+ continue ;
2067+
20732068 GlobalMMapInfo.insert (FileMMapInfo);
20742069 }
20752070
@@ -2121,22 +2116,12 @@ std::error_code DataAggregator::parseMMapEvents() {
21212116 << " using file offset 0x" << Twine::utohexstr (MMapInfo.Offset )
21222117 << " . Ignoring profile data for this mapping\n " ;
21232118 continue ;
2119+ } else {
2120+ MMapInfo.BaseAddress = *BaseAddress;
21242121 }
2125- MMapInfo.BaseAddress = *BaseAddress;
21262122 }
21272123
2128- // Try to add MMapInfo to the map and update its size. Large binaries may
2129- // span to multiple text segments, so the mapping is inserted only on the
2130- // first occurrence.
2131- if (!BinaryMMapInfo.insert (std::make_pair (MMapInfo.PID , MMapInfo)).second )
2132- assert (MMapInfo.BaseAddress == BinaryMMapInfo[MMapInfo.PID ].BaseAddress &&
2133- " Base address on multiple segment mappings should match" );
2134-
2135- // Update mapping size.
2136- const uint64_t EndAddress = MMapInfo.MMapAddress + MMapInfo.Size ;
2137- const uint64_t Size = EndAddress - BinaryMMapInfo[MMapInfo.PID ].BaseAddress ;
2138- if (Size > BinaryMMapInfo[MMapInfo.PID ].Size )
2139- BinaryMMapInfo[MMapInfo.PID ].Size = Size;
2124+ BinaryMMapInfo.insert (std::make_pair (MMapInfo.PID , MMapInfo));
21402125 }
21412126
21422127 if (BinaryMMapInfo.empty ()) {
0 commit comments