Skip to content

Commit c74aaf4

Browse files
[BOLT] Heatmap fix on large binaries and printing mappings.
1 parent 097e96d commit c74aaf4

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,8 +2009,9 @@ std::error_code DataAggregator::parseMMapEvents() {
20092009
return MI.second.PID == FileMMapInfo.second.PID;
20102010
});
20112011

2012-
if (PIDExists)
2013-
continue;
2012+
// let duplicates to the multimap.
2013+
// if (PIDExists)
2014+
// continue;
20142015

20152016
GlobalMMapInfo.insert(FileMMapInfo);
20162017
}
@@ -2067,7 +2068,17 @@ std::error_code DataAggregator::parseMMapEvents() {
20672068
}
20682069
}
20692070

2070-
BinaryMMapInfo.insert(std::make_pair(MMapInfo.PID, MMapInfo));
2071+
// The mapping was already in place, but there are cases where the size
2072+
// is wrong. Fix it if needed.
2073+
if(!BinaryMMapInfo.insert(std::make_pair(MMapInfo.PID, MMapInfo)).second) {
2074+
auto EndAddress = MMapInfo.MMapAddress + MMapInfo.Size;
2075+
auto FixedSize = EndAddress - BinaryMMapInfo[MMapInfo.PID].BaseAddress;
2076+
2077+
if (FixedSize != BinaryMMapInfo[MMapInfo.PID].Size) {
2078+
outs() << "MMap size fixed: " << Twine::utohexstr(FixedSize) << " \n";
2079+
BinaryMMapInfo[MMapInfo.PID].Size = FixedSize;
2080+
}
2081+
}
20712082
}
20722083

20732084
if (BinaryMMapInfo.empty()) {

bolt/lib/Profile/Heatmap.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ void Heatmap::print(raw_ostream &OS) const {
164164

165165
// Print map legend
166166
OS << "Legend:\n";
167+
OS << "\nRegions:\n";
167168
uint64_t PrevValue = 0;
168169
for (unsigned I = 0; I < sizeof(Range) / sizeof(Range[0]); ++I) {
169170
const uint64_t Value = Range[I];
@@ -173,6 +174,16 @@ void Heatmap::print(raw_ostream &OS) const {
173174
PrevValue = Value;
174175
}
175176

177+
{
178+
OS << "\nSections:\n";
179+
int Idx = 0;
180+
for (auto TxtSeg : TextSections) {
181+
OS << static_cast<char>('A' + ((Idx++) % 26)) << ": " << TxtSeg.Name
182+
<< ": 0x" << Twine::utohexstr(TxtSeg.BeginAddress) << "-0x"
183+
<< Twine::utohexstr(TxtSeg.EndAddress) << "\n";
184+
}
185+
}
186+
176187
// Pos - character position from right in hex form.
177188
auto printHeader = [&](unsigned Pos) {
178189
OS << " ";

0 commit comments

Comments
 (0)