Skip to content

Commit 3fe02c6

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.4 [skip ci]
2 parents 30dc1dc + 0289ca0 commit 3fe02c6

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
}
@@ -1216,8 +1217,8 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12161217
ErrorOr<StringRef> TypeOrErr = parseString(FieldSeparator);
12171218
if (std::error_code EC = TypeOrErr.getError())
12181219
return EC;
1219-
enum TType { TRACE, BRANCH, FT, FT_EXTERNAL_ORIGIN, INVALID };
1220-
auto Type = StringSwitch<TType>(TypeOrErr.get())
1220+
enum AggregatedLBREntry { TRACE, BRANCH, FT, FT_EXTERNAL_ORIGIN, INVALID };
1221+
auto Type = StringSwitch<AggregatedLBREntry>(TypeOrErr.get())
12211222
.Case("T", TRACE)
12221223
.Case("B", BRANCH)
12231224
.Case("F", FT)
@@ -1241,7 +1242,7 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12411242
return EC;
12421243

12431244
ErrorOr<Location> TraceFtEnd = std::error_code();
1244-
if (Type == TRACE) {
1245+
if (Type == AggregatedLBREntry::TRACE) {
12451246
while (checkAndConsumeFS()) {
12461247
}
12471248
TraceFtEnd = parseLocationOrOffset();
@@ -1251,12 +1252,13 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12511252

12521253
while (checkAndConsumeFS()) {
12531254
}
1254-
ErrorOr<int64_t> Frequency = parseNumberField(FieldSeparator, Type != BRANCH);
1255+
ErrorOr<int64_t> Frequency =
1256+
parseNumberField(FieldSeparator, Type != AggregatedLBREntry::BRANCH);
12551257
if (std::error_code EC = Frequency.getError())
12561258
return EC;
12571259

12581260
uint64_t Mispreds = 0;
1259-
if (Type == BRANCH) {
1261+
if (Type == AggregatedLBREntry::BRANCH) {
12601262
while (checkAndConsumeFS()) {
12611263
}
12621264
ErrorOr<int64_t> MispredsOrErr = parseNumberField(FieldSeparator, true);
@@ -1354,19 +1356,14 @@ std::error_code DataAggregator::printLBRHeatMap() {
13541356
exit(1);
13551357
}
13561358

1357-
if (opts::HeatmapStats) {
1358-
HM.printSectionHotness(outs());
1359-
return std::error_code();
1359+
HM.print(opts::HeatmapOutput);
1360+
if (opts::HeatmapOutput == "-") {
1361+
HM.printCDF(opts::HeatmapOutput);
1362+
HM.printSectionHotness(opts::HeatmapOutput);
1363+
} else {
1364+
HM.printCDF(opts::HeatmapOutput + ".csv");
1365+
HM.printSectionHotness(opts::HeatmapOutput + "-section-hotness.csv");
13601366
}
1361-
HM.print(opts::OutputFilename);
1362-
if (opts::OutputFilename == "-")
1363-
HM.printCDF(opts::OutputFilename);
1364-
else
1365-
HM.printCDF(opts::OutputFilename + ".csv");
1366-
if (opts::OutputFilename == "-")
1367-
HM.printSectionHotness(opts::OutputFilename);
1368-
else
1369-
HM.printSectionHotness(opts::OutputFilename + "-section-hotness.csv");
13701367

13711368
return std::error_code();
13721369
}
@@ -1393,7 +1390,7 @@ void DataAggregator::parseLBRSample(const PerfBranchSample &Sample,
13931390
const uint64_t TraceTo = NextLBR->From;
13941391
const BinaryFunction *TraceBF =
13951392
getBinaryFunctionContainingAddress(TraceFrom);
1396-
if (opts::HeatmapMode) {
1393+
if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive) {
13971394
FTInfo &Info = FallthroughLBRs[Trace(TraceFrom, TraceTo)];
13981395
++Info.InternCount;
13991396
} else if (TraceBF && TraceBF->containsAddress(TraceTo)) {
@@ -1431,7 +1428,7 @@ void DataAggregator::parseLBRSample(const PerfBranchSample &Sample,
14311428
NextLBR = &LBR;
14321429

14331430
// Record branches outside binary functions for heatmap.
1434-
if (opts::HeatmapMode) {
1431+
if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive) {
14351432
TakenBranchInfo &Info = BranchLBRs[Trace(LBR.From, LBR.To)];
14361433
++Info.TakenCount;
14371434
continue;
@@ -1446,7 +1443,8 @@ void DataAggregator::parseLBRSample(const PerfBranchSample &Sample,
14461443
}
14471444
// Record LBR addresses not covered by fallthroughs (bottom-of-stack source
14481445
// and top-of-stack target) as basic samples for heatmap.
1449-
if (opts::HeatmapMode && !Sample.LBR.empty()) {
1446+
if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive &&
1447+
!Sample.LBR.empty()) {
14501448
++BasicSamples[Sample.LBR.front().To];
14511449
++BasicSamples[Sample.LBR.back().From];
14521450
}
@@ -2231,8 +2229,8 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
22312229
for (const StringMapEntry<std::nullopt_t> &EventEntry : EventNames)
22322230
EventNamesOS << LS << EventEntry.first().str();
22332231

2234-
BP.Header.Flags =
2235-
opts::BasicAggregation ? BinaryFunction::PF_IP : BinaryFunction::PF_LBR;
2232+
BP.Header.Flags = opts::BasicAggregation ? BinaryFunction::PF_BASIC
2233+
: BinaryFunction::PF_BRANCH;
22362234

22372235
// Add probe inline tree nodes.
22382236
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)