Skip to content

Commit 6a183b8

Browse files
authored
Merge branch 'llvm:main' into v4i8reg
2 parents ef3d5de + 5e15997 commit 6a183b8

File tree

2,278 files changed

+82067
-31005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,278 files changed

+82067
-31005
lines changed

.github/CODEOWNERS

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
1+
# This file lists reviewers that are auto-assigned when a pull request modifies
2+
# certain files or directories. If you add yourself to this file, you commit to
3+
# reviewing a large fraction of pull requests in the relevant area.
4+
#
5+
# The GitHub "code owners" mechanism is used exclusively to auto-assign
6+
# reviewers and does not carry significance beyond that. It is not necessary
7+
# to receive an approval from a "code owner" in particular -- any LLVM project
8+
# member can approve pull requests.
9+
#
10+
# Note that GitHub's concept of "code owner" is independent from LLVM's own
11+
# "code owner" concept, they merely happen to share terminology. See
12+
# https://llvm.org/docs/DeveloperPolicy.html#code-owners, as well as the
13+
# CODE_OWNERS.txt files in the respective subproject directories.
14+
115
/libcxx/ @llvm/reviewers-libcxx
216
/libcxxabi/ @llvm/reviewers-libcxxabi
317
/libunwind/ @llvm/reviewers-libunwind
418
/runtimes/ @llvm/reviewers-libcxx
19+
20+
/llvm/lib/Analysis/BasicAliasAnalysis.cpp @nikic
21+
/llvm/lib/Analysis/InstructionSimplify.cpp @nikic
22+
/llvm/lib/Analysis/LazyValueInfo.cpp @nikic
23+
/llvm/lib/Analysis/ScalarEvolution.cpp @nikic
24+
/llvm/lib/Analysis/ValueTracking.cpp @nikic
25+
/llvm/lib/IR/ConstantRange.cpp @nikic
26+
/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp @nikic
27+
/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp @nikic
28+
/llvm/lib/Transforms/InstCombine/ @nikic
29+
30+
/clang/test/CXX/drs/ @Endilll
31+
/clang/www/cxx_dr_status.html @Endilll
32+
/clang/www/make_cxx_dr_status @Endilll

.github/new-issues-labeler.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
'libc++':
1111
- '/libc[+x]{2}(?!\-)/i'
1212

13-
'libc++-abi':
14-
- '/libc[+x]{2}-abi/i'
13+
'libc++abi':
14+
- '/libc[+x]{2}-?abi/i'
1515

1616
'libc':
1717
- '/\blibc(?![-+])\b/i'

.github/new-prs-labeler.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,6 @@ tools:llvm-mca:
309309
- llvm/include/llvm/MCA/**
310310
- llvm/lib/MCA/**
311311

312-
vectorizers:
313-
- llvm/lib/Transforms/Vectorize/**
314-
- llvm/include/llvm/Transforms/Vectorize/**
315-
316312
clang:
317313
- any:
318314
- clang/**

.github/workflows/llvm-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,17 @@ jobs:
170170
uses: actions/download-artifact@v3
171171
with:
172172
name: build-baseline
173+
path: build-baseline
173174
- name: Download latest
174175
uses: actions/download-artifact@v3
175176
with:
176177
name: build-latest
178+
path: build-latest
177179
- name: Download symbol list
178180
uses: actions/download-artifact@v3
179181
with:
180182
name: symbol-list
183+
path: symbol-list
181184

182185
- name: Install abi-compliance-checker
183186
run: sudo apt-get install abi-compliance-checker

.github/workflows/pr-code-format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Install clang-format
2828
uses: aminya/setup-cpp@v1
2929
with:
30-
clangformat: 16.0.6
30+
clangformat: 17.0.1
3131

3232
- name: Setup Python env
3333
uses: actions/setup-python@v4

.github/workflows/release-binaries.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
matrix:
6969
target:
7070
- triple: x86_64-linux-gnu-ubuntu-22.04
71-
runs-on: ubuntu-22.04-8x32
71+
runs-on: ubuntu-22.04-16x64
7272
debian-build-deps: >
7373
chrpath
7474
gcc-multilib

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,15 @@ class BinaryContext {
871871
return nullptr;
872872
}
873873

874+
/// Retrieves a reference to ELF's _GLOBAL_OFFSET_TABLE_ symbol, which points
875+
/// at GOT, or null if it is not present in the input binary symtab.
876+
BinaryData *getGOTSymbol();
877+
878+
/// Checks if symbol name refers to ELF's _GLOBAL_OFFSET_TABLE_ symbol
879+
bool isGOTSymbol(StringRef SymName) const {
880+
return SymName == "_GLOBAL_OFFSET_TABLE_";
881+
}
882+
874883
/// Return true if \p SymbolName was generated internally and was not present
875884
/// in the input binary.
876885
bool isInternalSymbolName(const StringRef Name) {

bolt/include/bolt/Core/Relocation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct Relocation {
8484

8585
/// Special relocation type that allows the linker to modify the instruction.
8686
static bool isX86GOTPCRELX(uint64_t Type);
87+
static bool isX86GOTPC64(uint64_t Type);
8788

8889
/// Return true if relocation type is NONE
8990
static bool isNone(uint64_t Type);

bolt/lib/Core/BinaryContext.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,31 @@ BinaryContext::getBinaryDataContainingAddressImpl(uint64_t Address) const {
10261026
return nullptr;
10271027
}
10281028

1029+
BinaryData *BinaryContext::getGOTSymbol() {
1030+
// First tries to find a global symbol with that name
1031+
BinaryData *GOTSymBD = getBinaryDataByName("_GLOBAL_OFFSET_TABLE_");
1032+
if (GOTSymBD)
1033+
return GOTSymBD;
1034+
1035+
// This symbol might be hidden from run-time link, so fetch the local
1036+
// definition if available.
1037+
GOTSymBD = getBinaryDataByName("_GLOBAL_OFFSET_TABLE_/1");
1038+
if (!GOTSymBD)
1039+
return nullptr;
1040+
1041+
// If the local symbol is not unique, fail
1042+
unsigned Index = 2;
1043+
SmallString<30> Storage;
1044+
while (const BinaryData *BD =
1045+
getBinaryDataByName(Twine("_GLOBAL_OFFSET_TABLE_/")
1046+
.concat(Twine(Index++))
1047+
.toStringRef(Storage)))
1048+
if (BD->getAddress() != GOTSymBD->getAddress())
1049+
return nullptr;
1050+
1051+
return GOTSymBD;
1052+
}
1053+
10291054
bool BinaryContext::setBinaryDataSize(uint64_t Address, uint64_t Size) {
10301055
auto NI = BinaryDataMap.find(Address);
10311056
assert(NI != BinaryDataMap.end());

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,8 @@ bool BinaryFunction::postProcessIndirectBranches(
17611761
uint64_t LastJT = 0;
17621762
uint16_t LastJTIndexReg = BC.MIB->getNoRegister();
17631763
for (BinaryBasicBlock &BB : blocks()) {
1764-
for (MCInst &Instr : BB) {
1764+
for (BinaryBasicBlock::iterator II = BB.begin(); II != BB.end(); ++II) {
1765+
MCInst &Instr = *II;
17651766
if (!BC.MIB->isIndirectBranch(Instr))
17661767
continue;
17671768

@@ -1789,7 +1790,7 @@ bool BinaryFunction::postProcessIndirectBranches(
17891790
const MCExpr *DispExpr;
17901791
MCInst *PCRelBaseInstr;
17911792
IndirectBranchType Type = BC.MIB->analyzeIndirectBranch(
1792-
Instr, BB.begin(), BB.end(), PtrSize, MemLocInstr, BaseRegNum,
1793+
Instr, BB.begin(), II, PtrSize, MemLocInstr, BaseRegNum,
17931794
IndexRegNum, DispValue, DispExpr, PCRelBaseInstr);
17941795
if (Type != IndirectBranchType::UNKNOWN || MemLocInstr != nullptr)
17951796
continue;

bolt/lib/Core/DebugData.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ void DebugAddrWriterDwarf5::update(DIEBuilder &DIEBlder, DWARFUnit &CU) {
495495
const endianness Endian =
496496
BC->DwCtx->isLittleEndian() ? support::little : support::big;
497497
const DWARFSection &AddrSec = BC->DwCtx->getDWARFObj().getAddrSection();
498-
DWARFDataExtractor AddrData(BC->DwCtx->getDWARFObj(), AddrSec, Endian, 0);
498+
DWARFDataExtractor AddrData(BC->DwCtx->getDWARFObj(), AddrSec,
499+
Endian == support::little, 0);
499500
DWARFDebugAddrTable AddrTable;
500501
DIDumpOptions DumpOpts;
501502
constexpr uint32_t HeaderSize = 8;

bolt/lib/Core/Relocation.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
using namespace llvm;
2121
using namespace bolt;
2222

23+
namespace ELFReserved {
24+
enum {
25+
R_RISCV_TPREL_I = 49,
26+
R_RISCV_TPREL_S = 50,
27+
};
28+
} // namespace ELFReserved
29+
2330
Triple::ArchType Relocation::Arch;
2431

2532
static bool isSupportedX86(uint64_t Type) {
@@ -35,6 +42,7 @@ static bool isSupportedX86(uint64_t Type) {
3542
case ELF::R_X86_64_PC32:
3643
case ELF::R_X86_64_PC64:
3744
case ELF::R_X86_64_PLT32:
45+
case ELF::R_X86_64_GOTPC64:
3846
case ELF::R_X86_64_GOTPCREL:
3947
case ELF::R_X86_64_GOTTPOFF:
4048
case ELF::R_X86_64_TPOFF32:
@@ -110,6 +118,13 @@ static bool isSupportedRISCV(uint64_t Type) {
110118
case ELF::R_RISCV_LO12_I:
111119
case ELF::R_RISCV_LO12_S:
112120
case ELF::R_RISCV_64:
121+
case ELF::R_RISCV_TLS_GOT_HI20:
122+
case ELF::R_RISCV_TPREL_HI20:
123+
case ELF::R_RISCV_TPREL_ADD:
124+
case ELF::R_RISCV_TPREL_LO12_I:
125+
case ELF::R_RISCV_TPREL_LO12_S:
126+
case ELFReserved::R_RISCV_TPREL_I:
127+
case ELFReserved::R_RISCV_TPREL_S:
113128
return true;
114129
}
115130
}
@@ -136,6 +151,7 @@ static size_t getSizeForTypeX86(uint64_t Type) {
136151
return 4;
137152
case ELF::R_X86_64_PC64:
138153
case ELF::R_X86_64_64:
154+
case ELF::R_X86_64_GOTPC64:
139155
return 8;
140156
}
141157
}
@@ -212,6 +228,7 @@ static size_t getSizeForTypeRISCV(uint64_t Type) {
212228
return 4;
213229
case ELF::R_RISCV_64:
214230
case ELF::R_RISCV_GOT_HI20:
231+
case ELF::R_RISCV_TLS_GOT_HI20:
215232
// See extractValueRISCV for why this is necessary.
216233
return 8;
217234
}
@@ -530,6 +547,7 @@ static uint64_t extractValueRISCV(uint64_t Type, uint64_t Contents,
530547
case ELF::R_RISCV_BRANCH:
531548
return extractBImmRISCV(Contents);
532549
case ELF::R_RISCV_GOT_HI20:
550+
case ELF::R_RISCV_TLS_GOT_HI20:
533551
// We need to know the exact address of the GOT entry so we extract the
534552
// value from both the AUIPC and L[D|W]. We cannot rely on the symbol in the
535553
// relocation for this since it simply refers to the object that is stored
@@ -598,6 +616,7 @@ static bool isGOTRISCV(uint64_t Type) {
598616
default:
599617
return false;
600618
case ELF::R_RISCV_GOT_HI20:
619+
case ELF::R_RISCV_TLS_GOT_HI20:
601620
return true;
602621
}
603622
}
@@ -634,6 +653,14 @@ static bool isTLSRISCV(uint64_t Type) {
634653
switch (Type) {
635654
default:
636655
return false;
656+
case ELF::R_RISCV_TLS_GOT_HI20:
657+
case ELF::R_RISCV_TPREL_HI20:
658+
case ELF::R_RISCV_TPREL_ADD:
659+
case ELF::R_RISCV_TPREL_LO12_I:
660+
case ELF::R_RISCV_TPREL_LO12_S:
661+
case ELFReserved::R_RISCV_TPREL_I:
662+
case ELFReserved::R_RISCV_TPREL_S:
663+
return true;
637664
}
638665
}
639666

@@ -655,6 +682,7 @@ static bool isPCRelativeX86(uint64_t Type) {
655682
case ELF::R_X86_64_PLT32:
656683
case ELF::R_X86_64_GOTOFF64:
657684
case ELF::R_X86_64_GOTPC32:
685+
case ELF::R_X86_64_GOTPC64:
658686
case ELF::R_X86_64_GOTTPOFF:
659687
case ELF::R_X86_64_GOTPCRELX:
660688
case ELF::R_X86_64_REX_GOTPCRELX:
@@ -730,6 +758,7 @@ static bool isPCRelativeRISCV(uint64_t Type) {
730758
case ELF::R_RISCV_RVC_JUMP:
731759
case ELF::R_RISCV_RVC_BRANCH:
732760
case ELF::R_RISCV_32_PCREL:
761+
case ELF::R_RISCV_TLS_GOT_HI20:
733762
return true;
734763
}
735764
}
@@ -797,6 +826,12 @@ bool Relocation::isX86GOTPCRELX(uint64_t Type) {
797826
return Type == ELF::R_X86_64_GOTPCRELX || Type == ELF::R_X86_64_REX_GOTPCRELX;
798827
}
799828

829+
bool Relocation::isX86GOTPC64(uint64_t Type) {
830+
if (Arch != Triple::x86_64)
831+
return false;
832+
return Type == ELF::R_X86_64_GOTPC64;
833+
}
834+
800835
bool Relocation::isNone(uint64_t Type) { return Type == getNone(); }
801836

802837
bool Relocation::isRelative(uint64_t Type) {

bolt/lib/Passes/ADRRelaxationPass.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ static cl::opt<bool>
2929
namespace llvm {
3030
namespace bolt {
3131

32+
// We don't exit directly from runOnFunction since it would call ThreadPool
33+
// destructor which might result in internal assert if we're not finished
34+
// creating async jobs on the moment of exit. So we're finishing all parallel
35+
// jobs and checking the exit flag after it.
36+
static bool PassFailed = false;
37+
3238
void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
39+
if (PassFailed)
40+
return;
41+
3342
BinaryContext &BC = BF.getBinaryContext();
3443
for (BinaryBasicBlock &BB : BF) {
3544
for (auto It = BB.begin(); It != BB.end(); ++It) {
@@ -54,8 +63,12 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
5463
MCPhysReg Reg;
5564
BC.MIB->getADRReg(Inst, Reg);
5665
int64_t Addend = BC.MIB->getTargetAddend(Inst);
57-
InstructionListType Addr =
58-
BC.MIB->materializeAddress(Symbol, BC.Ctx.get(), Reg, Addend);
66+
InstructionListType Addr;
67+
68+
{
69+
auto L = BC.scopeLock();
70+
Addr = BC.MIB->materializeAddress(Symbol, BC.Ctx.get(), Reg, Addend);
71+
}
5972

6073
if (It != BB.begin() && BC.MIB->isNoop(*std::prev(It))) {
6174
It = BB.eraseInstruction(std::prev(It));
@@ -68,7 +81,8 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
6881
errs() << formatv("BOLT-ERROR: Cannot relax adr in non-simple function "
6982
"{0}. Can't proceed in current mode.\n",
7083
BF.getOneName());
71-
exit(1);
84+
PassFailed = true;
85+
return;
7286
}
7387
It = BB.replaceInstruction(It, Addr);
7488
}
@@ -85,7 +99,10 @@ void ADRRelaxationPass::runOnFunctions(BinaryContext &BC) {
8599

86100
ParallelUtilities::runOnEachFunction(
87101
BC, ParallelUtilities::SchedulingPolicy::SP_TRIVIAL, WorkFun, nullptr,
88-
"ADRRelaxationPass", /* ForceSequential */ true);
102+
"ADRRelaxationPass");
103+
104+
if (PassFailed)
105+
exit(1);
89106
}
90107

91108
} // end namespace bolt

bolt/lib/Passes/Aligner.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,25 +158,27 @@ void AlignerPass::runOnFunctions(BinaryContext &BC) {
158158
BinaryContext::IndependentCodeEmitter Emitter =
159159
BC.createIndependentMCCodeEmitter();
160160

161-
if (opts::UseCompactAligner)
162-
alignCompact(BF, Emitter.MCE.get());
163-
else
164-
alignMaxBytes(BF);
165-
166161
// Align objects that contains constant islands and no code
167162
// to at least 8 bytes.
168163
if (!BF.size() && BF.hasIslandsInfo()) {
169-
const uint16_t Alignment = BF.getConstantIslandAlignment();
170-
if (BF.getAlignment() < Alignment)
171-
BF.setAlignment(Alignment);
172-
173-
if (BF.getMaxAlignmentBytes() < Alignment)
174-
BF.setMaxAlignmentBytes(Alignment);
175-
176-
if (BF.getMaxColdAlignmentBytes() < Alignment)
177-
BF.setMaxColdAlignmentBytes(Alignment);
164+
uint16_t Alignment = BF.getConstantIslandAlignment();
165+
// Check if we're forcing output alignment and it is greater than minimal
166+
// CI required one
167+
if (!opts::UseCompactAligner && Alignment < opts::AlignFunctions &&
168+
opts::AlignFunctions <= opts::AlignFunctionsMaxBytes)
169+
Alignment = opts::AlignFunctions;
170+
171+
BF.setAlignment(Alignment);
172+
BF.setMaxAlignmentBytes(Alignment);
173+
BF.setMaxColdAlignmentBytes(Alignment);
174+
return;
178175
}
179176

177+
if (opts::UseCompactAligner)
178+
alignCompact(BF, Emitter.MCE.get());
179+
else
180+
alignMaxBytes(BF);
181+
180182
if (opts::AlignBlocks && !opts::PreserveBlocksAlignment)
181183
alignBlocks(BF, Emitter.MCE.get());
182184
};

bolt/lib/Passes/FixRISCVCallsPass.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ void FixRISCVCallsPass::runOnFunction(BinaryFunction &BF) {
4343

4444
MCInst OldCall = *NextII;
4545
auto L = BC.scopeLock();
46-
MIB->createCall(*II, Target, Ctx);
46+
47+
if (MIB->isTailCall(*NextII))
48+
MIB->createTailCall(*II, Target, Ctx);
49+
else
50+
MIB->createCall(*II, Target, Ctx);
51+
4752
MIB->moveAnnotations(std::move(OldCall), *II);
4853

4954
// The original offset was set on the jalr of the auipc+jalr pair. Since

0 commit comments

Comments
 (0)