Skip to content

Commit 87241ac

Browse files
authored
Merge branch 'main' into inbelic/rs-resource-range-intervals
2 parents 042c3a0 + 0a68a9d commit 87241ac

File tree

1,283 files changed

+118696
-50790
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,283 files changed

+118696
-50790
lines changed

.ci/monolithic-linux.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function at-exit {
3838

3939
ccache --print-stats > artifacts/ccache_stats.txt
4040
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
41-
cp "${BUILD_DIR}"/test-results.*.xml artifacts/
41+
cp "${BUILD_DIR}"/test-results.*.xml artifacts/ || :
4242

4343
# If building fails there will be no results files.
4444
shopt -s nullglob
@@ -47,7 +47,7 @@ function at-exit {
4747
python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_buildkite.py ":linux: Linux x64 Test Results" \
4848
"linux-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml
4949
else
50-
python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py ":linux: Linux x64 Test Results" \
50+
python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py ":penguin: Linux x64 Test Results" \
5151
$retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
5252
fi
5353
}

.ci/monolithic-windows.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function at-exit {
3333
mkdir -p artifacts
3434
sccache --show-stats >> artifacts/sccache_stats.txt
3535
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
36-
cp "${BUILD_DIR}"/test-results.*.xml artifacts/
36+
cp "${BUILD_DIR}"/test-results.*.xml artifacts/ || :
3737

3838
# If building fails there will be no results files.
3939
shopt -s nullglob
@@ -42,7 +42,7 @@ function at-exit {
4242
python "${MONOREPO_ROOT}"/.ci/generate_test_report_buildkite.py ":windows: Windows x64 Test Results" \
4343
"windows-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml
4444
else
45-
python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py ":windows: Windows x64 Test Results" \
45+
python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py ":window: Windows x64 Test Results" \
4646
$retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
4747
fi
4848
}

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
/mlir/**/Transforms/SROA.* @moxinilian
129129

130130
# BOLT
131-
/bolt/ @aaupov @maksfb @rafaelauler @ayermolo @yota9
131+
/bolt/ @aaupov @maksfb @rafaelauler @ayermolo @yota9 @paschalis-mpeis
132132

133133
# Bazel build system.
134134
/utils/bazel/ @rupprecht @keith @aaronmondal

bolt/docs/Heatmaps.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ For the generation, the default bucket size was used with a line size of 128.
8989
Some useful options are:
9090

9191
```
92-
-line-size=<uint> - number of entries per line (default 256)
92+
-line-size=<uint> - number of entries per line (default 256).
93+
Use a smaller value (e.g. 128) if the heatmap doesn't fit
94+
the screen horizontally.
95+
-block-size=<initial size>[,<zoom-out size>,...] - heatmap bucket size,
96+
optionally followed by zoom-out sizes to produce coarse-
97+
grained heatmaps. Size can be specified in human-readable
98+
format with [kKmMgG][i][B] suffix. Default 64B, 4K, 256K.
9399
-max-address=<uint> - maximum address considered valid for heatmap (default 4GB)
94100
-print-mappings - print mappings in the legend, between characters/blocks and text sections (default false)
95101
```

bolt/include/bolt/Profile/Heatmap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ class Heatmap {
8585
void printSectionHotness(raw_ostream &OS) const;
8686

8787
size_t size() const { return Map.size(); }
88+
89+
/// Increase bucket size to \p NewSize, recomputing the heatmap.
90+
void resizeBucket(uint64_t NewSize);
8891
};
8992

9093
} // namespace bolt

bolt/include/bolt/Utils/CommandLineOpts.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ enum HeatmapModeKind {
2323
HM_Optional // perf2bolt --heatmap
2424
};
2525

26+
using HeatmapBlockSizes = std::vector<unsigned>;
27+
struct HeatmapBlockSpecParser : public llvm::cl::parser<HeatmapBlockSizes> {
28+
explicit HeatmapBlockSpecParser(llvm::cl::Option &O)
29+
: llvm::cl::parser<HeatmapBlockSizes>(O) {}
30+
// Return true on error.
31+
bool parse(llvm::cl::Option &O, llvm::StringRef ArgName, llvm::StringRef Arg,
32+
HeatmapBlockSizes &Val);
33+
};
34+
2635
extern HeatmapModeKind HeatmapMode;
2736
extern bool BinaryAnalysisMode;
2837

@@ -47,7 +56,8 @@ extern llvm::cl::opt<bool> EqualizeBBCounts;
4756
extern llvm::cl::opt<bool> ForcePatch;
4857
extern llvm::cl::opt<bool> RemoveSymtab;
4958
extern llvm::cl::opt<unsigned> ExecutionCountThreshold;
50-
extern llvm::cl::opt<unsigned> HeatmapBlock;
59+
extern llvm::cl::opt<HeatmapBlockSizes, false, HeatmapBlockSpecParser>
60+
HeatmapBlock;
5161
extern llvm::cl::opt<unsigned long long> HeatmapMaxAddress;
5262
extern llvm::cl::opt<unsigned long long> HeatmapMinAddress;
5363
extern llvm::cl::opt<bool> HeatmapPrintMappings;

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,8 +1314,9 @@ std::error_code DataAggregator::printLBRHeatMap() {
13141314
opts::HeatmapMaxAddress = 0xffffffffffffffff;
13151315
opts::HeatmapMinAddress = KernelBaseAddr;
13161316
}
1317-
Heatmap HM(opts::HeatmapBlock, opts::HeatmapMinAddress,
1318-
opts::HeatmapMaxAddress, getTextSections(BC));
1317+
opts::HeatmapBlockSizes &HMBS = opts::HeatmapBlock;
1318+
Heatmap HM(HMBS[0], opts::HeatmapMinAddress, opts::HeatmapMaxAddress,
1319+
getTextSections(BC));
13191320
auto getSymbolValue = [&](const MCSymbol *Symbol) -> uint64_t {
13201321
if (Symbol)
13211322
if (ErrorOr<uint64_t> SymValue = BC->getSymbolValue(*Symbol))
@@ -1365,6 +1366,14 @@ std::error_code DataAggregator::printLBRHeatMap() {
13651366
HM.printCDF(opts::HeatmapOutput + ".csv");
13661367
HM.printSectionHotness(opts::HeatmapOutput + "-section-hotness.csv");
13671368
}
1369+
// Provide coarse-grained heatmaps if requested via zoom-out scales
1370+
for (const uint64_t NewBucketSize : ArrayRef(HMBS).drop_front()) {
1371+
HM.resizeBucket(NewBucketSize);
1372+
if (opts::HeatmapOutput == "-")
1373+
HM.print(opts::HeatmapOutput);
1374+
else
1375+
HM.print(formatv("{0}-{1}", opts::HeatmapOutput, NewBucketSize).str());
1376+
}
13681377

13691378
return std::error_code();
13701379
}

bolt/lib/Profile/Heatmap.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ void Heatmap::print(StringRef FileName) const {
5555
errs() << "error opening output file: " << EC.message() << '\n';
5656
exit(1);
5757
}
58+
outs() << "HEATMAP: dumping heatmap with bucket size " << BucketSize << " to "
59+
<< FileName << '\n';
5860
print(OS);
5961
}
6062

@@ -364,5 +366,13 @@ void Heatmap::printSectionHotness(raw_ostream &OS) const {
364366
OS << formatv("[unmapped], 0x0, 0x0, {0:f4}, 0, 0\n",
365367
100.0 * UnmappedHotness / NumTotalCounts);
366368
}
369+
370+
void Heatmap::resizeBucket(uint64_t NewSize) {
371+
std::map<uint64_t, uint64_t> NewMap;
372+
for (const auto [Bucket, Count] : Map)
373+
NewMap[Bucket * BucketSize / NewSize] += Count;
374+
Map = NewMap;
375+
BucketSize = NewSize;
376+
}
367377
} // namespace bolt
368378
} // namespace llvm

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,19 @@ void RewriteInstance::discoverFileObjects() {
13411341
}
13421342
}
13431343
}
1344+
1345+
// The linker may omit data markers for absolute long veneers. Introduce
1346+
// those markers artificially to assist the disassembler.
1347+
for (BinaryFunction &BF :
1348+
llvm::make_second_range(BC->getBinaryFunctions())) {
1349+
if (BF.getOneName().starts_with("__AArch64AbsLongThunk_") &&
1350+
BF.getSize() == 16 && !BF.getSizeOfDataInCodeAt(8)) {
1351+
BC->errs() << "BOLT-WARNING: missing data marker detected in veneer "
1352+
<< BF << '\n';
1353+
BF.markDataAtOffset(8);
1354+
BC->AddressToConstantIslandMap[BF.getAddress() + 8] = &BF;
1355+
}
1356+
}
13441357
}
13451358

13461359
if (!BC->IsLinuxKernel) {

bolt/lib/Utils/CommandLineOpts.cpp

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "bolt/Utils/CommandLineOpts.h"
1414
#include "VCSVersion.inc"
15+
#include "llvm/Support/Regex.h"
1516

1617
using namespace llvm;
1718

@@ -103,10 +104,56 @@ ExecutionCountThreshold("execution-count-threshold",
103104
cl::Hidden,
104105
cl::cat(BoltOptCategory));
105106

106-
cl::opt<unsigned>
107-
HeatmapBlock("block-size",
108-
cl::desc("size of a heat map block in bytes (default 64)"),
109-
cl::init(64), cl::cat(HeatmapCategory));
107+
bool HeatmapBlockSpecParser::parse(cl::Option &O, StringRef ArgName,
108+
StringRef Arg, HeatmapBlockSizes &Val) {
109+
// Parses a human-readable suffix into a shift amount or nullopt on error.
110+
auto parseSuffix = [](StringRef Suffix) -> std::optional<unsigned> {
111+
if (Suffix.empty())
112+
return 0;
113+
if (!Regex{"^[kKmMgG]i?[bB]?$"}.match(Suffix))
114+
return std::nullopt;
115+
// clang-format off
116+
switch (Suffix.front()) {
117+
case 'k': case 'K': return 10;
118+
case 'm': case 'M': return 20;
119+
case 'g': case 'G': return 30;
120+
}
121+
// clang-format on
122+
llvm_unreachable("Unexpected suffix");
123+
};
124+
125+
SmallVector<StringRef> Sizes;
126+
Arg.split(Sizes, ',');
127+
unsigned PreviousSize = 0;
128+
for (StringRef Size : Sizes) {
129+
StringRef OrigSize = Size;
130+
unsigned &SizeVal = Val.emplace_back(0);
131+
if (Size.consumeInteger(10, SizeVal)) {
132+
O.error("'" + OrigSize + "' value can't be parsed as an integer");
133+
return true;
134+
}
135+
if (std::optional<unsigned> ShiftAmt = parseSuffix(Size)) {
136+
SizeVal <<= *ShiftAmt;
137+
} else {
138+
O.error("'" + Size + "' value can't be parsed as a suffix");
139+
return true;
140+
}
141+
if (SizeVal <= PreviousSize || (PreviousSize && SizeVal % PreviousSize)) {
142+
O.error("'" + OrigSize + "' must be a multiple of previous value");
143+
return true;
144+
}
145+
PreviousSize = SizeVal;
146+
}
147+
return false;
148+
}
149+
150+
cl::opt<opts::HeatmapBlockSizes, false, opts::HeatmapBlockSpecParser>
151+
HeatmapBlock(
152+
"block-size", cl::value_desc("initial_size{,zoom-out_size,...}"),
153+
cl::desc("heatmap bucket size, optionally followed by zoom-out sizes "
154+
"for coarse-grained heatmaps (default 64B, 4K, 256K)."),
155+
cl::init(HeatmapBlockSizes{/*Initial*/ 64, /*Zoom-out*/ 4096, 262144}),
156+
cl::cat(HeatmapCategory));
110157

111158
cl::opt<unsigned long long> HeatmapMaxAddress(
112159
"max-address", cl::init(0xffffffff),

0 commit comments

Comments
 (0)