Skip to content

Commit 2d0f730

Browse files
authored
Merge branch 'main' into impl-any-of-reduction-vplan
2 parents b571247 + f710b04 commit 2d0f730

File tree

1,993 files changed

+104200
-38418
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,993 files changed

+104200
-38418
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ concurrency:
3333
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
3434
cancel-in-progress: true
3535

36-
37-
env:
38-
# LLVM POST-BRANCH bump version
39-
# LLVM POST-BRANCH add compiler test for ToT - 1, e.g. "Clang 17"
40-
# LLVM RELEASE bump remove compiler ToT - 3, e.g. "Clang 15"
41-
LLVM_HEAD_VERSION: "19" # Used compiler, update POST-BRANCH.
42-
LLVM_PREVIOUS_VERSION: "18"
43-
LLVM_OLDEST_VERSION: "17"
44-
GCC_STABLE_VERSION: "13"
45-
LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-19"
46-
CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
47-
4836
jobs:
4937
stage1:
5038
if: github.repository_owner == 'llvm'

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,6 +2407,19 @@ inline raw_ostream &operator<<(raw_ostream &OS,
24072407
return OS;
24082408
}
24092409

2410+
/// Compare function by index if it is valid, fall back to the original address
2411+
/// otherwise.
2412+
inline bool compareBinaryFunctionByIndex(const BinaryFunction *A,
2413+
const BinaryFunction *B) {
2414+
if (A->hasValidIndex() && B->hasValidIndex())
2415+
return A->getIndex() < B->getIndex();
2416+
if (A->hasValidIndex() && !B->hasValidIndex())
2417+
return true;
2418+
if (!A->hasValidIndex() && B->hasValidIndex())
2419+
return false;
2420+
return A->getAddress() < B->getAddress();
2421+
}
2422+
24102423
} // namespace bolt
24112424

24122425
// GraphTraits specializations for function basic block graphs (CFGs)

bolt/lib/Core/BinaryContext.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,13 +1607,7 @@ std::vector<BinaryFunction *> BinaryContext::getSortedFunctions() {
16071607
SortedFunctions.begin(),
16081608
[](BinaryFunction &BF) { return &BF; });
16091609

1610-
llvm::stable_sort(SortedFunctions,
1611-
[](const BinaryFunction *A, const BinaryFunction *B) {
1612-
if (A->hasValidIndex() && B->hasValidIndex()) {
1613-
return A->getIndex() < B->getIndex();
1614-
}
1615-
return A->hasValidIndex();
1616-
});
1610+
llvm::stable_sort(SortedFunctions, compareBinaryFunctionByIndex);
16171611
return SortedFunctions;
16181612
}
16191613

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -923,9 +923,21 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
923923
// As a solution, for fixed-address binaries we set LPStart to 0, and for
924924
// position-independent binaries we offset LP start by one byte.
925925
bool NeedsLPAdjustment = false;
926-
const MCSymbol *LPStartSymbol = nullptr;
927926
std::function<void(const MCSymbol *)> emitLandingPad;
928-
if (BC.HasFixedLoadAddress) {
927+
928+
// Check if there's a symbol associated with a landing pad fragment.
929+
const MCSymbol *LPStartSymbol = BF.getLPStartSymbol(FF.getFragmentNum());
930+
if (!LPStartSymbol) {
931+
// Since landing pads are not in the same fragment, we fall back to emitting
932+
// absolute addresses for this FDE.
933+
if (opts::Verbosity >= 2) {
934+
BC.outs() << "BOLT-INFO: falling back to generating absolute-address "
935+
<< "exception ranges for " << BF << '\n';
936+
}
937+
938+
assert(BC.HasFixedLoadAddress &&
939+
"Cannot emit absolute-address landing pads for PIE/DSO");
940+
929941
Streamer.emitIntValue(dwarf::DW_EH_PE_udata4, 1); // LPStart format
930942
Streamer.emitIntValue(0, 4); // LPStart
931943
emitLandingPad = [&](const MCSymbol *LPSymbol) {
@@ -936,9 +948,6 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
936948
};
937949
} else {
938950
std::optional<FragmentNum> LPFN = BF.getLPFragment(FF.getFragmentNum());
939-
LPStartSymbol = BF.getLPStartSymbol(FF.getFragmentNum());
940-
assert(LPFN && LPStartSymbol && "Expected LPStart symbol to be set");
941-
942951
const FunctionFragment &LPFragment = BF.getLayout().getFragment(*LPFN);
943952
NeedsLPAdjustment =
944953
(!LPFragment.empty() && LPFragment.front()->isLandingPad());
@@ -987,7 +996,7 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
987996

988997
// Emit encoding of entries in the call site table. The format is used for the
989998
// call site start, length, and corresponding landing pad.
990-
if (BC.HasFixedLoadAddress)
999+
if (!LPStartSymbol)
9911000
Streamer.emitIntValue(dwarf::DW_EH_PE_sdata4, 1);
9921001
else
9931002
Streamer.emitIntValue(dwarf::DW_EH_PE_uleb128, 1);
@@ -1007,7 +1016,7 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
10071016

10081017
// Start of the range is emitted relative to the start of current
10091018
// function split part.
1010-
if (BC.HasFixedLoadAddress) {
1019+
if (!LPStartSymbol) {
10111020
Streamer.emitAbsoluteSymbolDiff(BeginLabel, StartSymbol, 4);
10121021
Streamer.emitAbsoluteSymbolDiff(EndLabel, BeginLabel, 4);
10131022
} else {

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -385,16 +385,7 @@ bool BinaryFunction::isForwardCall(const MCSymbol *CalleeSymbol) const {
385385
if (CalleeBF) {
386386
if (CalleeBF->isInjected())
387387
return true;
388-
389-
if (hasValidIndex() && CalleeBF->hasValidIndex()) {
390-
return getIndex() < CalleeBF->getIndex();
391-
} else if (hasValidIndex() && !CalleeBF->hasValidIndex()) {
392-
return true;
393-
} else if (!hasValidIndex() && CalleeBF->hasValidIndex()) {
394-
return false;
395-
} else {
396-
return getAddress() < CalleeBF->getAddress();
397-
}
388+
return compareBinaryFunctionByIndex(this, CalleeBF);
398389
} else {
399390
// Absolute symbol.
400391
ErrorOr<uint64_t> CalleeAddressOrError = BC.getSymbolValue(*CalleeSymbol);

bolt/lib/Passes/ReorderFunctions.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -473,16 +473,7 @@ Error ReorderFunctions::runOnFunctions(BinaryContext &BC) {
473473
[](BinaryFunction &BF) { return &BF; });
474474

475475
// Sort functions by index.
476-
llvm::stable_sort(SortedFunctions,
477-
[](const BinaryFunction *A, const BinaryFunction *B) {
478-
if (A->hasValidIndex() && B->hasValidIndex())
479-
return A->getIndex() < B->getIndex();
480-
if (A->hasValidIndex() && !B->hasValidIndex())
481-
return true;
482-
if (!A->hasValidIndex() && B->hasValidIndex())
483-
return false;
484-
return A->getAddress() < B->getAddress();
485-
});
476+
llvm::stable_sort(SortedFunctions, compareBinaryFunctionByIndex);
486477

487478
for (const BinaryFunction *Func : SortedFunctions) {
488479
if (!Func->hasValidIndex())

bolt/lib/Passes/SplitFunctions.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ void SplitFunctions::splitFunction(BinaryFunction &BF, SplitStrategy &S) {
901901
// have to be placed in the same fragment. When we split them, create
902902
// trampoline landing pads that will redirect the execution to real LPs.
903903
TrampolineSetType Trampolines;
904-
if (!BC.HasFixedLoadAddress && BF.hasEHRanges() && BF.isSplit()) {
904+
if (BF.hasEHRanges() && BF.isSplit()) {
905905
// If all landing pads for this fragment are grouped in one (potentially
906906
// different) fragment, we can set LPStart to the start of that fragment
907907
// and avoid trampoline code.
@@ -925,8 +925,12 @@ void SplitFunctions::splitFunction(BinaryFunction &BF, SplitStrategy &S) {
925925
} else if (LandingPadFragments.size() == 1) {
926926
BF.setLPFragment(FF.getFragmentNum(), LandingPadFragments.front());
927927
} else {
928-
NeedsTrampolines = true;
929-
break;
928+
if (!BC.HasFixedLoadAddress) {
929+
NeedsTrampolines = true;
930+
break;
931+
} else {
932+
BF.setLPFragment(FF.getFragmentNum(), std::nullopt);
933+
}
930934
}
931935
}
932936

bolt/test/AArch64/data-at-0-offset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang %cflags -O2 -fPIE -Wl,-q -pie %s -o %t.exe
1+
// RUN: %clang %cflags -O2 -fPIE -std=gnu99 -Wl,-q -pie %s -o %t.exe
22
// RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
33
// CHECK-NOT: BOLT-WARNING: unable to disassemble instruction at offset
44

bolt/test/AArch64/double_jump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// A contrived example to test the double jump removal peephole.
22

3-
// RUN: %clang %cflags -O0 %s -o %t.exe
3+
// RUN: %clangxx %cxxflags -O0 %s -o %t.exe
44
// RUN: llvm-bolt %t.exe -o %t.bolt --peepholes=double-jumps | \
55
// RUN: FileCheck %s -check-prefix=CHECKBOLT
66
// RUN: llvm-objdump --no-print-imm-hex -d %t.bolt | FileCheck %s

bolt/test/R_ABS.pic.lld.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* with libc available.
77
* REQUIRES: system-linux
88
*
9-
* RUN: %clang %cflags -fPIC -shared %s -o %t.so -Wl,-q -fuse-ld=lld
9+
* RUN: %clangxx %cxxflags -fPIC -shared %s -o %t.so -Wl,-q -fuse-ld=lld
1010
* RUN: llvm-bolt %t.so -o %t.so.bolt --relocs
1111
*/
1212

0 commit comments

Comments
 (0)