Skip to content

Commit 994f045

Browse files
committed
rebase
Created using spr 1.3.4
2 parents be3f1ba + 3fe02c6 commit 994f045

File tree

1,351 files changed

+116369
-58616
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,351 files changed

+116369
-58616
lines changed

.github/workflows/containers/github-action-ci-windows/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ RUN choco install -y handle
108108
109109
RUN pip3 install pywin32 buildbot-worker==2.8.4
110110
111-
ARG RUNNER_VERSION=2.323.0
111+
ARG RUNNER_VERSION=2.324.0
112112
ENV RUNNER_VERSION=$RUNNER_VERSION
113113
114114
RUN powershell -Command \

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM docker.io/library/ubuntu:24.04 as base
22
ENV LLVM_SYSROOT=/opt/llvm
33

44
FROM base as stage1-toolchain
5-
ENV LLVM_VERSION=20.1.1
5+
ENV LLVM_VERSION=20.1.4
66

77
RUN apt-get update && \
88
apt-get install -y \
@@ -86,7 +86,7 @@ WORKDIR /home/gha
8686

8787
FROM ci-container as ci-container-agent
8888

89-
ENV GITHUB_RUNNER_VERSION=2.323.0
89+
ENV GITHUB_RUNNER_VERSION=2.324.0
9090

9191
RUN mkdir actions-runner && \
9292
cd actions-runner && \

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ class BinaryFunction {
142142
/// Types of profile the function can use. Could be a combination.
143143
enum {
144144
PF_NONE = 0, /// No profile.
145-
PF_LBR = 1, /// Profile is based on last branch records.
146-
PF_IP = 2, /// Non-LBR sample-based profile.
145+
PF_BRANCH = 1, /// Profile is based on branches or branch stacks.
146+
PF_BASIC = 2, /// Non-branch IP sample-based profile.
147147
PF_MEMEVENT = 4, /// Profile has mem events.
148148
};
149149

bolt/include/bolt/Profile/ProfileYAMLMapping.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ LLVM_YAML_STRONG_TYPEDEF(uint16_t, PROFILE_PF)
230230

231231
template <> struct ScalarBitSetTraits<PROFILE_PF> {
232232
static void bitset(IO &io, PROFILE_PF &value) {
233-
io.bitSetCase(value, "lbr", BinaryFunction::PF_LBR);
234-
io.bitSetCase(value, "sample", BinaryFunction::PF_IP);
233+
io.bitSetCase(value, "lbr", BinaryFunction::PF_BRANCH);
234+
io.bitSetCase(value, "sample", BinaryFunction::PF_BASIC);
235235
io.bitSetCase(value, "memevent", BinaryFunction::PF_MEMEVENT);
236236
}
237237
};

bolt/include/bolt/Utils/CommandLineOpts.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717

1818
namespace opts {
1919

20-
extern bool HeatmapMode;
20+
enum HeatmapModeKind {
21+
HM_None = 0,
22+
HM_Exclusive, // llvm-bolt-heatmap
23+
HM_Optional // perf2bolt --heatmap
24+
};
25+
26+
extern HeatmapModeKind HeatmapMode;
2127
extern bool BinaryAnalysisMode;
2228

2329
extern llvm::cl::OptionCategory BoltCategory;
@@ -45,7 +51,7 @@ extern llvm::cl::opt<unsigned> HeatmapBlock;
4551
extern llvm::cl::opt<unsigned long long> HeatmapMaxAddress;
4652
extern llvm::cl::opt<unsigned long long> HeatmapMinAddress;
4753
extern llvm::cl::opt<bool> HeatmapPrintMappings;
48-
extern llvm::cl::opt<bool> HeatmapStats;
54+
extern llvm::cl::opt<std::string> HeatmapOutput;
4955
extern llvm::cl::opt<bool> HotData;
5056
extern llvm::cl::opt<bool> HotFunctionsAtEnd;
5157
extern llvm::cl::opt<bool> HotText;

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extern cl::opt<bool> UpdateDebugSections;
6666
extern cl::opt<unsigned> Verbosity;
6767

6868
extern bool BinaryAnalysisMode;
69-
extern bool HeatmapMode;
69+
extern HeatmapModeKind HeatmapMode;
7070
extern bool processAllFunctions();
7171

7272
static cl::opt<bool> CheckEncoding(

bolt/lib/Core/BinaryFunctionProfile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void BinaryFunction::postProcessProfile() {
7070
return;
7171
}
7272

73-
if (!(getProfileFlags() & PF_LBR))
73+
if (!(getProfileFlags() & PF_BRANCH))
7474
return;
7575

7676
// If we have at least some branch data for the function indicate that it

bolt/lib/Passes/MCF.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,15 @@ void EstimateEdgeCounts::runOnFunction(BinaryFunction &BF) {
458458
Error EstimateEdgeCounts::runOnFunctions(BinaryContext &BC) {
459459
if (llvm::none_of(llvm::make_second_range(BC.getBinaryFunctions()),
460460
[](const BinaryFunction &BF) {
461-
return BF.getProfileFlags() == BinaryFunction::PF_IP;
461+
return BF.getProfileFlags() == BinaryFunction::PF_BASIC;
462462
}))
463463
return Error::success();
464464

465465
ParallelUtilities::WorkFuncTy WorkFun = [&](BinaryFunction &BF) {
466466
runOnFunction(BF);
467467
};
468468
ParallelUtilities::PredicateTy SkipFunc = [&](const BinaryFunction &BF) {
469-
return BF.getProfileFlags() != BinaryFunction::PF_IP;
469+
return BF.getProfileFlags() != BinaryFunction::PF_BASIC;
470470
};
471471

472472
ParallelUtilities::runOnEachFunction(

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ void DataAggregator::findPerfExecutable() {
164164
void DataAggregator::start() {
165165
outs() << "PERF2BOLT: Starting data aggregation job for " << Filename << "\n";
166166

167-
// Turn on heatmap building if requested by --print-heatmap-stats flag.
168-
if (opts::HeatmapStats)
169-
opts::HeatmapMode = true;
167+
// Turn on heatmap building if requested by --heatmap flag.
168+
if (!opts::HeatmapMode && opts::HeatmapOutput.getNumOccurrences())
169+
opts::HeatmapMode = opts::HeatmapModeKind::HM_Optional;
170170

171171
// Don't launch perf for pre-aggregated files or when perf input is specified
172172
// by the user.
@@ -520,9 +520,10 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
520520
if (std::error_code EC = printLBRHeatMap())
521521
return errorCodeToError(EC);
522522

523-
if (opts::HeatmapStats)
523+
if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Optional)
524524
return Error::success();
525525

526+
assert(opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive);
526527
exit(0);
527528
}
528529

@@ -570,11 +571,11 @@ void DataAggregator::processProfile(BinaryContext &BC) {
570571
for (auto &BFI : BC.getBinaryFunctions()) {
571572
BinaryFunction &BF = BFI.second;
572573
if (FuncBranchData *FBD = getBranchData(BF)) {
573-
BF.markProfiled(BinaryFunction::PF_LBR);
574+
BF.markProfiled(BinaryFunction::PF_BRANCH);
574575
BF.RawSampleCount = FBD->getNumExecutedBranches();
575576
} else if (FuncBasicSampleData *FSD =
576577
getFuncBasicSampleData(BF.getNames())) {
577-
BF.markProfiled(BinaryFunction::PF_IP);
578+
BF.markProfiled(BinaryFunction::PF_BASIC);
578579
BF.RawSampleCount = FSD->getSamples();
579580
}
580581
}
@@ -1209,8 +1210,8 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12091210
ErrorOr<StringRef> TypeOrErr = parseString(FieldSeparator);
12101211
if (std::error_code EC = TypeOrErr.getError())
12111212
return EC;
1212-
enum TType { TRACE, BRANCH, FT, FT_EXTERNAL_ORIGIN, INVALID };
1213-
auto Type = StringSwitch<TType>(TypeOrErr.get())
1213+
enum AggregatedLBREntry { TRACE, BRANCH, FT, FT_EXTERNAL_ORIGIN, INVALID };
1214+
auto Type = StringSwitch<AggregatedLBREntry>(TypeOrErr.get())
12141215
.Case("T", TRACE)
12151216
.Case("B", BRANCH)
12161217
.Case("F", FT)
@@ -1234,7 +1235,7 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12341235
return EC;
12351236

12361237
ErrorOr<Location> TraceFtEnd = std::error_code();
1237-
if (Type == TRACE) {
1238+
if (Type == AggregatedLBREntry::TRACE) {
12381239
while (checkAndConsumeFS()) {
12391240
}
12401241
TraceFtEnd = parseLocationOrOffset();
@@ -1244,12 +1245,13 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12441245

12451246
while (checkAndConsumeFS()) {
12461247
}
1247-
ErrorOr<int64_t> Frequency = parseNumberField(FieldSeparator, Type != BRANCH);
1248+
ErrorOr<int64_t> Frequency =
1249+
parseNumberField(FieldSeparator, Type != AggregatedLBREntry::BRANCH);
12481250
if (std::error_code EC = Frequency.getError())
12491251
return EC;
12501252

12511253
uint64_t Mispreds = 0;
1252-
if (Type == BRANCH) {
1254+
if (Type == AggregatedLBREntry::BRANCH) {
12531255
while (checkAndConsumeFS()) {
12541256
}
12551257
ErrorOr<int64_t> MispredsOrErr = parseNumberField(FieldSeparator, true);
@@ -1347,19 +1349,14 @@ std::error_code DataAggregator::printLBRHeatMap() {
13471349
exit(1);
13481350
}
13491351

1350-
if (opts::HeatmapStats) {
1351-
HM.printSectionHotness(outs());
1352-
return std::error_code();
1352+
HM.print(opts::HeatmapOutput);
1353+
if (opts::HeatmapOutput == "-") {
1354+
HM.printCDF(opts::HeatmapOutput);
1355+
HM.printSectionHotness(opts::HeatmapOutput);
1356+
} else {
1357+
HM.printCDF(opts::HeatmapOutput + ".csv");
1358+
HM.printSectionHotness(opts::HeatmapOutput + "-section-hotness.csv");
13531359
}
1354-
HM.print(opts::OutputFilename);
1355-
if (opts::OutputFilename == "-")
1356-
HM.printCDF(opts::OutputFilename);
1357-
else
1358-
HM.printCDF(opts::OutputFilename + ".csv");
1359-
if (opts::OutputFilename == "-")
1360-
HM.printSectionHotness(opts::OutputFilename);
1361-
else
1362-
HM.printSectionHotness(opts::OutputFilename + "-section-hotness.csv");
13631360

13641361
return std::error_code();
13651362
}
@@ -1386,7 +1383,7 @@ void DataAggregator::parseLBRSample(const PerfBranchSample &Sample,
13861383
const uint64_t TraceTo = NextLBR->From;
13871384
const BinaryFunction *TraceBF =
13881385
getBinaryFunctionContainingAddress(TraceFrom);
1389-
if (opts::HeatmapMode) {
1386+
if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive) {
13901387
FTInfo &Info = FallthroughLBRs[Trace(TraceFrom, TraceTo)];
13911388
++Info.InternCount;
13921389
} else if (TraceBF && TraceBF->containsAddress(TraceTo)) {
@@ -1424,7 +1421,7 @@ void DataAggregator::parseLBRSample(const PerfBranchSample &Sample,
14241421
NextLBR = &LBR;
14251422

14261423
// Record branches outside binary functions for heatmap.
1427-
if (opts::HeatmapMode) {
1424+
if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive) {
14281425
TakenBranchInfo &Info = BranchLBRs[Trace(LBR.From, LBR.To)];
14291426
++Info.TakenCount;
14301427
continue;
@@ -1439,7 +1436,8 @@ void DataAggregator::parseLBRSample(const PerfBranchSample &Sample,
14391436
}
14401437
// Record LBR addresses not covered by fallthroughs (bottom-of-stack source
14411438
// and top-of-stack target) as basic samples for heatmap.
1442-
if (opts::HeatmapMode && !Sample.LBR.empty()) {
1439+
if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive &&
1440+
!Sample.LBR.empty()) {
14431441
++BasicSamples[Sample.LBR.front().To];
14441442
++BasicSamples[Sample.LBR.back().From];
14451443
}
@@ -2208,8 +2206,8 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
22082206
for (const StringMapEntry<std::nullopt_t> &EventEntry : EventNames)
22092207
EventNamesOS << LS << EventEntry.first().str();
22102208

2211-
BP.Header.Flags =
2212-
opts::BasicAggregation ? BinaryFunction::PF_IP : BinaryFunction::PF_LBR;
2209+
BP.Header.Flags = opts::BasicAggregation ? BinaryFunction::PF_BASIC
2210+
: BinaryFunction::PF_BRANCH;
22132211

22142212
// Add probe inline tree nodes.
22152213
YAMLProfileWriter::InlineTreeDesc InlineTree;

bolt/lib/Profile/DataReader.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,12 @@ void DataReader::readProfile(BinaryFunction &BF) {
358358
return;
359359

360360
if (!hasLBR()) {
361-
BF.ProfileFlags = BinaryFunction::PF_IP;
361+
BF.ProfileFlags = BinaryFunction::PF_BASIC;
362362
readBasicSampleData(BF);
363363
return;
364364
}
365365

366-
BF.ProfileFlags = BinaryFunction::PF_LBR;
366+
BF.ProfileFlags = BinaryFunction::PF_BRANCH;
367367

368368
// Possibly assign/re-assign branch profile data.
369369
matchProfileData(BF);
@@ -1035,9 +1035,8 @@ ErrorOr<BasicSampleInfo> DataReader::parseSampleInfo() {
10351035
}
10361036

10371037
ErrorOr<bool> DataReader::maybeParseNoLBRFlag() {
1038-
if (ParsingBuf.size() < 6 || ParsingBuf.substr(0, 6) != "no_lbr")
1038+
if (!ParsingBuf.consume_front("no_lbr"))
10391039
return false;
1040-
ParsingBuf = ParsingBuf.drop_front(6);
10411040
Col += 6;
10421041

10431042
if (ParsingBuf.size() > 0 && ParsingBuf[0] == ' ')
@@ -1058,9 +1057,8 @@ ErrorOr<bool> DataReader::maybeParseNoLBRFlag() {
10581057
}
10591058

10601059
ErrorOr<bool> DataReader::maybeParseBATFlag() {
1061-
if (ParsingBuf.size() < 16 || ParsingBuf.substr(0, 16) != "boltedcollection")
1060+
if (!ParsingBuf.consume_front("boltedcollection"))
10621061
return false;
1063-
ParsingBuf = ParsingBuf.drop_front(16);
10641062
Col += 16;
10651063

10661064
if (!checkAndConsumeNewLine()) {

0 commit comments

Comments
 (0)