Skip to content

Commit 275c254

Browse files
authored
Merge branch 'main' into for-each-segment
2 parents 216b957 + fd452da commit 275c254

File tree

1,862 files changed

+70340
-56125
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,862 files changed

+70340
-56125
lines changed

.ci/monolithic-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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/new-prs-labeler.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,12 @@ flang:fir-hlfir:
554554
flang:codegen:
555555
- flang/**/CodeGen/**
556556

557+
llvm:codegen:
558+
- llvm/lib/CodeGen/*
559+
- llvm/lib/CodeGen/MIRParser/*
560+
- llvm/lib/CodeGen/LiveDebugValues/*
561+
- llvm/lib/CodeGen/AsmPrinter/*
562+
557563
llvm:globalisel:
558564
- llvm/**/GlobalISel/**
559565
- llvm/utils/TableGen/GlobalISel*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ RUN powershell -Command \
8585
RUN git config --system core.longpaths true & \
8686
git config --global core.autocrlf false
8787
88-
ARG RUNNER_VERSION=2.324.0
88+
ARG RUNNER_VERSION=2.325.0
8989
ENV RUNNER_VERSION=$RUNNER_VERSION
9090
9191
RUN powershell -Command \

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ WORKDIR /home/gha
8686

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

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

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

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,7 @@ class BinaryFunction {
23482348
releaseCFG();
23492349
CurrentState = State::Emitted;
23502350
}
2351+
clearList(Relocations);
23512352
}
23522353

23532354
/// Process LSDA information for the function.

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -370,33 +370,46 @@ class DataAggregator : public DataReader {
370370
/// memory.
371371
///
372372
/// File format syntax:
373-
/// {B|F|f|T} [<start_id>:]<start_offset> [<end_id>:]<end_offset> [<ft_end>]
374-
/// <count> [<mispred_count>]
373+
/// E <event>
374+
/// S <start> <count>
375+
/// T <start> <end> <ft_end> <count>
376+
/// B <start> <end> <count> <mispred_count>
377+
/// [Ff] <start> <end> <count>
375378
///
376-
/// B - indicates an aggregated branch
377-
/// F - an aggregated fall-through
379+
/// where <start>, <end>, <ft_end> have the format [<id>:]<offset>
380+
///
381+
/// E - name of the sampling event used for subsequent entries
382+
/// S - indicates an aggregated basic sample at <start>
383+
/// B - indicates an aggregated branch from <start> to <end>
384+
/// F - an aggregated fall-through from <start> to <end>
378385
/// f - an aggregated fall-through with external origin - used to disambiguate
379386
/// between a return hitting a basic block head and a regular internal
380387
/// jump to the block
381-
/// T - an aggregated trace: branch with a fall-through (from, to, ft_end)
382-
///
383-
/// <start_id> - build id of the object containing the start address. We can
384-
/// skip it for the main binary and use "X" for an unknown object. This will
385-
/// save some space and facilitate human parsing.
386-
///
387-
/// <start_offset> - hex offset from the object base load address (0 for the
388-
/// main executable unless it's PIE) to the start address.
388+
/// T - an aggregated trace: branch from <start> to <end> with a fall-through
389+
/// to <ft_end>
389390
///
390-
/// <end_id>, <end_offset> - same for the end address.
391+
/// <id> - build id of the object containing the address. We can skip it for
392+
/// the main binary and use "X" for an unknown object. This will save some
393+
/// space and facilitate human parsing.
391394
///
392-
/// <ft_end> - same for the fallthrough_end address.
395+
/// <offset> - hex offset from the object base load address (0 for the
396+
/// main executable unless it's PIE) to the address.
393397
///
394-
/// <count> - total aggregated count of the branch or a fall-through.
398+
/// <count> - total aggregated count.
395399
///
396400
/// <mispred_count> - the number of times the branch was mispredicted.
397-
/// Omitted for fall-throughs.
398401
///
399402
/// Example:
403+
/// Basic samples profile:
404+
/// E cycles
405+
/// S 41be50 3
406+
/// E br_inst_retired.near_taken
407+
/// S 41be60 6
408+
///
409+
/// Trace profile combining branches and fall-throughs:
410+
/// T 4b196f 4b19e0 4b19ef 2
411+
///
412+
/// Legacy branch profile with separate branches and fall-throughs:
400413
/// F 41be50 41be50 3
401414
/// F 41be90 41be90 4
402415
/// B 4b1942 39b57f0 3 0

bolt/lib/Core/BinaryContext.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,10 +1032,8 @@ void BinaryContext::adjustCodePadding() {
10321032

10331033
if (!hasValidCodePadding(BF)) {
10341034
if (HasRelocations) {
1035-
if (opts::Verbosity >= 1) {
1036-
this->outs() << "BOLT-INFO: function " << BF
1037-
<< " has invalid padding. Ignoring the function.\n";
1038-
}
1035+
this->errs() << "BOLT-WARNING: function " << BF
1036+
<< " has invalid padding. Ignoring the function\n";
10391037
BF.setIgnored();
10401038
} else {
10411039
BF.setMaxSize(BF.getSize());

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,8 +1526,6 @@ Error BinaryFunction::disassemble() {
15261526
if (uint64_t Offset = getFirstInstructionOffset())
15271527
Labels[Offset] = BC.Ctx->createNamedTempSymbol();
15281528

1529-
clearList(Relocations);
1530-
15311529
if (!IsSimple) {
15321530
clearList(Instructions);
15331531
return createNonFatalBOLTError("");
@@ -3244,16 +3242,26 @@ void BinaryFunction::setTrapOnEntry() {
32443242
}
32453243

32463244
void BinaryFunction::setIgnored() {
3245+
IsIgnored = true;
3246+
32473247
if (opts::processAllFunctions()) {
32483248
// We can accept ignored functions before they've been disassembled.
3249-
// In that case, they would still get disassembled and emited, but not
3249+
// In that case, they would still get disassembled and emitted, but not
32503250
// optimized.
3251-
assert(CurrentState == State::Empty &&
3252-
"cannot ignore non-empty functions in current mode");
3253-
IsIgnored = true;
3251+
if (CurrentState != State::Empty) {
3252+
BC.errs() << "BOLT-ERROR: cannot ignore non-empty function " << *this
3253+
<< " in current mode\n";
3254+
exit(1);
3255+
}
32543256
return;
32553257
}
32563258

3259+
IsSimple = false;
3260+
LLVM_DEBUG(dbgs() << "Ignoring " << getPrintName() << '\n');
3261+
3262+
if (CurrentState == State::Empty)
3263+
return;
3264+
32573265
clearDisasmState();
32583266

32593267
// Clear CFG state too.
@@ -3273,9 +3281,11 @@ void BinaryFunction::setIgnored() {
32733281

32743282
CurrentState = State::Empty;
32753283

3276-
IsIgnored = true;
3277-
IsSimple = false;
3278-
LLVM_DEBUG(dbgs() << "Ignoring " << getPrintName() << '\n');
3284+
// Fix external references in the original function body.
3285+
if (BC.HasRelocations) {
3286+
LLVM_DEBUG(dbgs() << "Scanning refs in " << *this << '\n');
3287+
scanExternalRefs();
3288+
}
32793289
}
32803290

32813291
void BinaryFunction::duplicateConstantIslands() {
@@ -3764,7 +3774,6 @@ void BinaryFunction::postProcessBranches() {
37643774

37653775
MCSymbol *BinaryFunction::addEntryPointAtOffset(uint64_t Offset) {
37663776
assert(Offset && "cannot add primary entry point");
3767-
assert(CurrentState == State::Empty || CurrentState == State::Disassembled);
37683777

37693778
const uint64_t EntryPointAddress = getAddress() + Offset;
37703779
MCSymbol *LocalSymbol = getOrCreateLocalLabel(EntryPointAddress);
@@ -3773,6 +3782,8 @@ MCSymbol *BinaryFunction::addEntryPointAtOffset(uint64_t Offset) {
37733782
if (EntrySymbol)
37743783
return EntrySymbol;
37753784

3785+
assert(CurrentState == State::Empty || CurrentState == State::Disassembled);
3786+
37763787
if (BinaryData *EntryBD = BC.getBinaryDataAtAddress(EntryPointAddress)) {
37773788
EntrySymbol = EntryBD->getSymbol();
37783789
} else {

bolt/lib/Passes/ADRRelaxationPass.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,15 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
8181
It = BB.eraseInstruction(std::prev(It));
8282
} else if (std::next(It) != BB.end() && BC.MIB->isNoop(*std::next(It))) {
8383
BB.eraseInstruction(std::next(It));
84-
} else if (!opts::StrictMode && !BF.isSimple()) {
84+
} else if (!BF.isSimple()) {
8585
// If the function is not simple, it may contain a jump table undetected
8686
// by us. This jump table may use an offset from the branch instruction
8787
// to land in the desired place. If we add new instructions, we
8888
// invalidate this offset, so we have to rely on linker-inserted NOP to
8989
// replace it with ADRP, and abort if it is not present.
9090
auto L = BC.scopeLock();
91-
BC.errs() << formatv(
92-
"BOLT-ERROR: Cannot relax adr in non-simple function "
93-
"{0}. Use --strict option to override\n",
94-
BF.getOneName());
91+
BC.errs() << "BOLT-ERROR: cannot relax ADR in non-simple function "
92+
<< BF << '\n';
9593
PassFailed = true;
9694
return;
9795
}

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 80 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,77 +1204,106 @@ ErrorOr<Location> DataAggregator::parseLocationOrOffset() {
12041204
}
12051205

12061206
std::error_code DataAggregator::parseAggregatedLBREntry() {
1207-
while (checkAndConsumeFS()) {
1208-
}
1207+
enum AggregatedLBREntry : char {
1208+
INVALID = 0,
1209+
EVENT_NAME, // E
1210+
TRACE, // T
1211+
SAMPLE, // S
1212+
BRANCH, // B
1213+
FT, // F
1214+
FT_EXTERNAL_ORIGIN // f
1215+
} Type = INVALID;
1216+
1217+
// The number of fields to parse, set based on Type.
1218+
int AddrNum = 0;
1219+
int CounterNum = 0;
1220+
// Storage for parsed fields.
1221+
StringRef EventName;
1222+
std::optional<Location> Addr[3];
1223+
int64_t Counters[2] = {0};
1224+
1225+
while (Type == INVALID || Type == EVENT_NAME) {
1226+
while (checkAndConsumeFS()) {
1227+
}
1228+
ErrorOr<StringRef> StrOrErr =
1229+
parseString(FieldSeparator, Type == EVENT_NAME);
1230+
if (std::error_code EC = StrOrErr.getError())
1231+
return EC;
1232+
StringRef Str = StrOrErr.get();
12091233

1210-
ErrorOr<StringRef> TypeOrErr = parseString(FieldSeparator);
1211-
if (std::error_code EC = TypeOrErr.getError())
1212-
return EC;
1213-
enum AggregatedLBREntry { TRACE, BRANCH, FT, FT_EXTERNAL_ORIGIN, INVALID };
1214-
auto Type = StringSwitch<AggregatedLBREntry>(TypeOrErr.get())
1215-
.Case("T", TRACE)
1216-
.Case("B", BRANCH)
1217-
.Case("F", FT)
1218-
.Case("f", FT_EXTERNAL_ORIGIN)
1219-
.Default(INVALID);
1220-
if (Type == INVALID) {
1221-
reportError("expected T, B, F or f");
1222-
return make_error_code(llvm::errc::io_error);
1223-
}
1234+
if (Type == EVENT_NAME) {
1235+
EventName = Str;
1236+
break;
1237+
}
12241238

1225-
while (checkAndConsumeFS()) {
1226-
}
1227-
ErrorOr<Location> From = parseLocationOrOffset();
1228-
if (std::error_code EC = From.getError())
1229-
return EC;
1239+
Type = StringSwitch<AggregatedLBREntry>(Str)
1240+
.Case("T", TRACE)
1241+
.Case("S", SAMPLE)
1242+
.Case("E", EVENT_NAME)
1243+
.Case("B", BRANCH)
1244+
.Case("F", FT)
1245+
.Case("f", FT_EXTERNAL_ORIGIN)
1246+
.Default(INVALID);
1247+
1248+
if (Type == INVALID) {
1249+
reportError("expected T, S, E, B, F or f");
1250+
return make_error_code(llvm::errc::io_error);
1251+
}
12301252

1231-
while (checkAndConsumeFS()) {
1253+
using SSI = StringSwitch<int>;
1254+
AddrNum = SSI(Str).Case("T", 3).Case("S", 1).Case("E", 0).Default(2);
1255+
CounterNum = SSI(Str).Case("B", 2).Case("E", 0).Default(1);
12321256
}
1233-
ErrorOr<Location> To = parseLocationOrOffset();
1234-
if (std::error_code EC = To.getError())
1235-
return EC;
12361257

1237-
ErrorOr<Location> TraceFtEnd = std::error_code();
1238-
if (Type == AggregatedLBREntry::TRACE) {
1258+
for (int I = 0; I < AddrNum; ++I) {
12391259
while (checkAndConsumeFS()) {
12401260
}
1241-
TraceFtEnd = parseLocationOrOffset();
1242-
if (std::error_code EC = TraceFtEnd.getError())
1261+
ErrorOr<Location> AddrOrErr = parseLocationOrOffset();
1262+
if (std::error_code EC = AddrOrErr.getError())
12431263
return EC;
1264+
Addr[I] = AddrOrErr.get();
12441265
}
12451266

1246-
while (checkAndConsumeFS()) {
1247-
}
1248-
ErrorOr<int64_t> Frequency =
1249-
parseNumberField(FieldSeparator, Type != AggregatedLBREntry::BRANCH);
1250-
if (std::error_code EC = Frequency.getError())
1251-
return EC;
1252-
1253-
uint64_t Mispreds = 0;
1254-
if (Type == AggregatedLBREntry::BRANCH) {
1267+
for (int I = 0; I < CounterNum; ++I) {
12551268
while (checkAndConsumeFS()) {
12561269
}
1257-
ErrorOr<int64_t> MispredsOrErr = parseNumberField(FieldSeparator, true);
1258-
if (std::error_code EC = MispredsOrErr.getError())
1270+
ErrorOr<int64_t> CountOrErr =
1271+
parseNumberField(FieldSeparator, I + 1 == CounterNum);
1272+
if (std::error_code EC = CountOrErr.getError())
12591273
return EC;
1260-
Mispreds = static_cast<uint64_t>(MispredsOrErr.get());
1274+
Counters[I] = CountOrErr.get();
12611275
}
12621276

12631277
if (!checkAndConsumeNewLine()) {
12641278
reportError("expected end of line");
12651279
return make_error_code(llvm::errc::io_error);
12661280
}
12671281

1268-
BinaryFunction *FromFunc = getBinaryFunctionContainingAddress(From->Offset);
1269-
BinaryFunction *ToFunc = getBinaryFunctionContainingAddress(To->Offset);
1282+
if (Type == EVENT_NAME) {
1283+
EventNames.insert(EventName);
1284+
return std::error_code();
1285+
}
12701286

1271-
for (BinaryFunction *BF : {FromFunc, ToFunc})
1272-
if (BF)
1273-
BF->setHasProfileAvailable();
1287+
const uint64_t FromOffset = Addr[0]->Offset;
1288+
BinaryFunction *FromFunc = getBinaryFunctionContainingAddress(FromOffset);
1289+
if (FromFunc)
1290+
FromFunc->setHasProfileAvailable();
1291+
1292+
int64_t Count = Counters[0];
1293+
int64_t Mispreds = Counters[1];
1294+
1295+
if (Type == SAMPLE) {
1296+
BasicSamples[FromOffset] += Count;
1297+
NumTotalSamples += Count;
1298+
return std::error_code();
1299+
}
12741300

1275-
uint64_t Count = static_cast<uint64_t>(Frequency.get());
1301+
const uint64_t ToOffset = Addr[1]->Offset;
1302+
BinaryFunction *ToFunc = getBinaryFunctionContainingAddress(ToOffset);
1303+
if (ToFunc)
1304+
ToFunc->setHasProfileAvailable();
12761305

1277-
Trace Trace(From->Offset, To->Offset);
1306+
Trace Trace(FromOffset, ToOffset);
12781307
// Taken trace
12791308
if (Type == TRACE || Type == BRANCH) {
12801309
TakenBranchInfo &Info = BranchLBRs[Trace];
@@ -1285,8 +1314,9 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12851314
}
12861315
// Construct fallthrough part of the trace
12871316
if (Type == TRACE) {
1288-
Trace.From = To->Offset;
1289-
Trace.To = TraceFtEnd->Offset;
1317+
const uint64_t TraceFtEndOffset = Addr[2]->Offset;
1318+
Trace.From = ToOffset;
1319+
Trace.To = TraceFtEndOffset;
12901320
Type = FromFunc == ToFunc ? FT : FT_EXTERNAL_ORIGIN;
12911321
}
12921322
// Add fallthrough trace

0 commit comments

Comments
 (0)