Skip to content

Commit 45042a4

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-remove-region-before-cg
2 parents 9cae5f7 + f557672 commit 45042a4

File tree

1,527 files changed

+70919
-41104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,527 files changed

+70919
-41104
lines changed

.github/new-prs-labeler.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ mlgo:
702702
- llvm/unittests/CodeGen/ML*
703703
- llvm/test/CodeGen/MLRegAlloc/**
704704
- llvm/utils/mlgo-utils/**
705+
- llvm/docs/MLGO.rst
705706

706707
tools:llvm-exegesis:
707708
- llvm/tools/llvm-exegesis/**

bolt/include/bolt/Profile/Heatmap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class Heatmap {
5252
: BucketSize(BucketSize), MinAddress(MinAddress), MaxAddress(MaxAddress),
5353
TextSections(TextSections) {}
5454

55+
uint64_t HotStart{0};
56+
uint64_t HotEnd{0};
57+
5558
inline bool ignoreAddress(uint64_t Address) const {
5659
return (Address > MaxAddress) || (Address < MinAddress);
5760
}

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3326,7 +3326,7 @@ void BinaryFunction::duplicateConstantIslands() {
33263326
static std::string constructFilename(std::string Filename,
33273327
std::string Annotation,
33283328
std::string Suffix) {
3329-
std::replace(Filename.begin(), Filename.end(), '/', '-');
3329+
llvm::replace(Filename, '/', '-');
33303330
if (!Annotation.empty())
33313331
Annotation.insert(0, "-");
33323332
if (Filename.size() + Annotation.size() + Suffix.size() > MAX_PATH) {

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@ getUnitForOffset(DIEBuilder &Builder, DWARFContext &DWCtx,
437437
// This is a work around for XCode clang. There is a build error when we
438438
// pass DWCtx.compile_units() to llvm::upper_bound
439439
std::call_once(InitVectorFlag, initCUVector);
440-
auto CUIter = std::upper_bound(CUOffsets.begin(), CUOffsets.end(), Offset,
441-
[](uint64_t LHS, const DWARFUnit *RHS) {
442-
return LHS < RHS->getNextUnitOffset();
443-
});
440+
auto CUIter = llvm::upper_bound(CUOffsets, Offset,
441+
[](uint64_t LHS, const DWARFUnit *RHS) {
442+
return LHS < RHS->getNextUnitOffset();
443+
});
444444
CU = CUIter != CUOffsets.end() ? (*CUIter) : nullptr;
445445
}
446446
return CU;

bolt/lib/Passes/AsmDump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void dumpFunction(const BinaryFunction &BF) {
109109
}
110110

111111
std::string PrintName = BF.getPrintName();
112-
std::replace(PrintName.begin(), PrintName.end(), '/', '-');
112+
llvm::replace(PrintName, '/', '-');
113113
std::string Filename =
114114
opts::AsmDump.empty()
115115
? (PrintName + ".s")

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static const char *dynoStatsOptName(const bolt::DynoStats::Category C) {
3535

3636
OptNames[C] = bolt::DynoStats::Description(C);
3737

38-
std::replace(OptNames[C].begin(), OptNames[C].end(), ' ', '-');
38+
llvm::replace(OptNames[C], ' ', '-');
3939

4040
return OptNames[C].c_str();
4141
}

bolt/lib/Passes/PettisAndHansen.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,10 @@ std::vector<Cluster> pettisAndHansen(const CallGraph &Cg) {
143143
// Find an arc with max weight and merge its nodes
144144

145145
while (!Carcs.empty()) {
146-
auto Maxpos =
147-
std::max_element(Carcs.begin(), Carcs.end(),
148-
[&](const ClusterArc &Carc1, const ClusterArc &Carc2) {
149-
return Carc1.Weight < Carc2.Weight;
150-
});
146+
auto Maxpos = llvm::max_element(
147+
Carcs, [&](const ClusterArc &Carc1, const ClusterArc &Carc2) {
148+
return Carc1.Weight < Carc2.Weight;
149+
});
151150

152151
ClusterArc Max = *Maxpos;
153152
Carcs.erase(Maxpos);

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,14 @@ std::error_code DataAggregator::printLBRHeatMap() {
13161316
}
13171317
Heatmap HM(opts::HeatmapBlock, opts::HeatmapMinAddress,
13181318
opts::HeatmapMaxAddress, getTextSections(BC));
1319+
auto getSymbolValue = [&](const MCSymbol *Symbol) -> uint64_t {
1320+
if (Symbol)
1321+
if (ErrorOr<uint64_t> SymValue = BC->getSymbolValue(*Symbol))
1322+
return SymValue.get();
1323+
return 0;
1324+
};
1325+
HM.HotStart = getSymbolValue(BC->getHotTextStartSymbol());
1326+
HM.HotEnd = getSymbolValue(BC->getHotTextEndSymbol());
13191327

13201328
if (!NumTotalSamples) {
13211329
if (opts::BasicAggregation) {

bolt/lib/Profile/Heatmap.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
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;

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,9 @@ void RewriteInstance::discoverFileObjects() {
968968
continue;
969969
}
970970

971-
// Ignore input hot markers
972-
if (SymName == "__hot_start" || SymName == "__hot_end")
971+
// Ignore input hot markers unless in heatmap mode
972+
if ((SymName == "__hot_start" || SymName == "__hot_end") &&
973+
!opts::HeatmapMode)
973974
continue;
974975

975976
FileSymRefs.emplace(SymbolAddress, Symbol);

0 commit comments

Comments
 (0)