Skip to content

Commit adcb146

Browse files
authored
Merge branch 'main' into fix/fixit-unknown-attributes
2 parents 4075ec4 + 68a346f commit adcb146

File tree

1,587 files changed

+59751
-52993
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,587 files changed

+59751
-52993
lines changed

.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/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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12201220
// Storage for parsed fields.
12211221
StringRef EventName;
12221222
std::optional<Location> Addr[3];
1223-
int64_t Counters[2];
1223+
int64_t Counters[2] = {0};
12241224

12251225
while (Type == INVALID || Type == EVENT_NAME) {
12261226
while (checkAndConsumeFS()) {

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3446,6 +3446,7 @@ void RewriteInstance::disassembleFunctions() {
34463446
BC->outs() << "BOLT-INFO: could not disassemble function " << Function
34473447
<< ". Will ignore.\n";
34483448
// Forcefully ignore the function.
3449+
Function.scanExternalRefs();
34493450
Function.setIgnored();
34503451
});
34513452

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Check that llvm-bolt generates a proper error message when ADR instruction
2+
## cannot be relaxed.
3+
4+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
5+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static
6+
# RUN: not llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
7+
# RUN: not llvm-bolt %t.exe -o %t.bolt --strict 2>&1 | FileCheck %s
8+
9+
# CHECK: BOLT-ERROR: cannot relax ADR in non-simple function _start
10+
11+
## The function contains unknown control flow and llvm-bolt fails to recover
12+
## CFG. As BOLT has to preserve the function layout, the ADR instruction cannot
13+
## be relaxed into ADRP+ADD.
14+
.text
15+
.globl _start
16+
.type _start, %function
17+
_start:
18+
.cfi_startproc
19+
adr x1, foo
20+
adr x2, .L1
21+
.L1:
22+
br x0
23+
ret x0
24+
.cfi_endproc
25+
.size _start, .-_start
26+
27+
.globl foo
28+
.type foo, %function
29+
foo:
30+
.cfi_startproc
31+
ret x0
32+
.cfi_endproc
33+
.size foo, .-foo

0 commit comments

Comments
 (0)