88
99#include " bolt/Profile/Heatmap.h"
1010#include " bolt/Utils/CommandLineOpts.h"
11+ #include " llvm/ADT/AddressRanges.h"
1112#include " llvm/ADT/StringMap.h"
1213#include " llvm/ADT/Twine.h"
1314#include " llvm/Support/Debug.h"
@@ -313,6 +314,9 @@ void Heatmap::printSectionHotness(raw_ostream &OS) const {
313314 UnmappedHotness += Frequency;
314315 };
315316
317+ AddressRange HotTextRange (HotStart, HotEnd);
318+ StringRef HotTextName = " [hot text]" ;
319+
316320 for (const std::pair<const uint64_t , uint64_t > &KV : Map) {
317321 NumTotalCounts += KV.second ;
318322 // We map an address bucket to the first section (lowest address)
@@ -328,15 +332,24 @@ void Heatmap::printSectionHotness(raw_ostream &OS) const {
328332 }
329333 SectionHotness[TextSections[TextSectionIndex].Name ] += KV.second ;
330334 ++BucketUtilization[TextSections[TextSectionIndex].Name ];
335+ if (HotTextRange.contains (Address)) {
336+ SectionHotness[HotTextName] += KV.second ;
337+ ++BucketUtilization[HotTextName];
338+ }
331339 }
332340
341+ std::vector<SectionNameAndRange> Sections (TextSections);
342+ // Append synthetic hot text section to TextSections
343+ if (!HotTextRange.empty ())
344+ Sections.emplace_back (SectionNameAndRange{HotTextName, HotStart, HotEnd});
345+
333346 assert (NumTotalCounts > 0 &&
334347 " total number of heatmap buckets should be greater than 0" );
335348
336349 OS << " Section Name, Begin Address, End Address, Percentage Hotness, "
337350 << " Utilization Pct, Partition Score\n " ;
338351 const uint64_t MappedCounts = NumTotalCounts - UnmappedHotness;
339- for (const auto [Name, Begin, End] : TextSections ) {
352+ for (const auto [Name, Begin, End] : Sections ) {
340353 const float Hotness = 1 . * SectionHotness[Name] / NumTotalCounts;
341354 const float MappedHotness =
342355 MappedCounts ? 1 . * SectionHotness[Name] / MappedCounts : 0 ;
0 commit comments