Skip to content

Commit 1e00028

Browse files
committed
Merge remote-tracking branch 'origin/main' into loop-vectorize/VPReductionRecipe-RecurKind
2 parents c244065 + 01f0425 commit 1e00028

File tree

1,757 files changed

+154828
-206234
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,757 files changed

+154828
-206234
lines changed

.ci/compute-projects.sh

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ function compute-projects-to-test() {
1818
shift
1919
projects=${@}
2020
for project in ${projects}; do
21+
echo "${project}"
2122
case ${project} in
2223
lld)
23-
for p in lld bolt cross-project-tests; do
24+
for p in bolt cross-project-tests; do
2425
echo $p
2526
done
2627
;;
2728
llvm)
28-
for p in llvm bolt clang clang-tools-extra lld lldb mlir polly; do
29+
for p in bolt clang clang-tools-extra lld lldb mlir polly; do
2930
echo $p
3031
done
3132
# Flang is not stable in Windows CI at the moment
@@ -35,30 +36,21 @@ function compute-projects-to-test() {
3536
;;
3637
clang)
3738
# lldb is temporarily removed to alleviate Linux pre-commit CI waiting times
38-
for p in clang clang-tools-extra compiler-rt cross-project-tests; do
39+
for p in clang-tools-extra compiler-rt cross-project-tests; do
3940
echo $p
4041
done
4142
;;
4243
clang-tools-extra)
43-
for p in clang-tools-extra libc; do
44-
echo $p
45-
done
44+
echo libc
4645
;;
4746
mlir)
48-
echo mlir
49-
# Flang is not stable in Windows CI at the moment
50-
if [[ $isForWindows == 0 ]]; then
51-
echo flang
52-
fi
53-
;;
54-
flang-rt)
5547
# Flang is not stable in Windows CI at the moment
5648
if [[ $isForWindows == 0 ]]; then
5749
echo flang
5850
fi
5951
;;
6052
*)
61-
echo "${project}"
53+
# Nothing to do
6254
;;
6355
esac
6456
done
@@ -73,11 +65,6 @@ function compute-runtimes-to-test() {
7365
echo $p
7466
done
7567
;;
76-
flang)
77-
for p in flang-rt; do
78-
echo $p
79-
done
80-
;;
8168
*)
8269
# Nothing to do
8370
;;

.ci/generate-buildkite-pipeline-premerge

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fi
7373
# needs while letting them run on the infrastructure provided by LLVM.
7474

7575
# Figure out which projects need to be built on each platform
76-
all_projects="bolt clang clang-tools-extra compiler-rt cross-project-tests flang flang-rt libc libclc lld lldb llvm mlir openmp polly pstl"
76+
all_projects="bolt clang clang-tools-extra compiler-rt cross-project-tests flang libc libclc lld lldb llvm mlir openmp polly pstl"
7777
modified_projects="$(keep-modified-projects ${all_projects})"
7878

7979
linux_projects_to_test=$(exclude-linux $(compute-projects-to-test 0 ${modified_projects}))

.ci/metrics/metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# This means we essentially have a list of workflows sorted by creation date,
4444
# and that's all we can deduce from it. So for each iteration, we'll blindly
4545
# process the last N workflows.
46-
GITHUB_WORKFLOWS_MAX_PROCESS_COUNT = 1000
46+
GITHUB_WORKFLOWS_MAX_PROCESS_COUNT = 2000
4747
# Second reason for the cut: reaching a workflow older than X.
4848
# This means we will miss long-tails (exceptional jobs running for more than
4949
# X hours), but that's also the case with the count cutoff above.

.ci/monolithic-linux.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
6565
-D CMAKE_CXX_FLAGS=-gmlt \
6666
-D LLVM_CCACHE_BUILD=ON \
6767
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
68-
-D FLANG_ENABLE_FLANG_RT=OFF \
6968
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
7069

7170
echo "--- ninja"
@@ -96,9 +95,6 @@ if [[ "${runtimes}" != "" ]]; then
9695
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
9796
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
9897
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
99-
-D CMAKE_Fortran_COMPILER="${BUILD_DIR}/bin/flang" \
100-
-D CMAKE_Fortran_COMPILER_WORKS=ON \
101-
-D LLVM_BINARY_DIR="${BUILD_DIR}" \
10298
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
10399
-D LIBCXX_CXX_ABI=libcxxabi \
104100
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
@@ -117,9 +113,6 @@ if [[ "${runtimes}" != "" ]]; then
117113
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
118114
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
119115
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
120-
-D CMAKE_Fortran_COMPILER="${BUILD_DIR}/bin/flang" \
121-
-D CMAKE_Fortran_COMPILER_WORKS=ON \
122-
-D LLVM_BINARY_DIR="${BUILD_DIR}" \
123116
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
124117
-D LIBCXX_CXX_ABI=libcxxabi \
125118
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
@@ -138,9 +131,6 @@ if [[ "${runtimes}" != "" ]]; then
138131
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
139132
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
140133
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
141-
-D CMAKE_Fortran_COMPILER="${BUILD_DIR}/bin/flang" \
142-
-D CMAKE_Fortran_COMPILER_WORKS=ON \
143-
-D LLVM_BINARY_DIR="${BUILD_DIR}" \
144134
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
145135
-D LIBCXX_CXX_ABI=libcxxabi \
146136
-D CMAKE_BUILD_TYPE=RelWithDebInfo \

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
stage1:
3838
if: github.repository_owner == 'llvm'
3939
runs-on: libcxx-self-hosted-linux
40-
container: ghcr.io/llvm/libcxx-linux-builder:b319dfef21f6c7b0bc6a356d6b9f41a3b3b98ae9
40+
container: ghcr.io/llvm/libcxx-linux-builder:b6bb9dc5abd7c6452c13a53fa8949cb259db459b
4141
continue-on-error: false
4242
strategy:
4343
fail-fast: false
@@ -75,7 +75,7 @@ jobs:
7575
stage2:
7676
if: github.repository_owner == 'llvm'
7777
runs-on: libcxx-self-hosted-linux
78-
container: ghcr.io/llvm/libcxx-linux-builder:b319dfef21f6c7b0bc6a356d6b9f41a3b3b98ae9
78+
container: ghcr.io/llvm/libcxx-linux-builder:b6bb9dc5abd7c6452c13a53fa8949cb259db459b
7979
needs: [ stage1 ]
8080
continue-on-error: false
8181
strategy:
@@ -167,7 +167,7 @@ jobs:
167167
- config: 'generic-msan'
168168
machine: libcxx-self-hosted-linux
169169
runs-on: ${{ matrix.machine }}
170-
container: ghcr.io/llvm/libcxx-linux-builder:b319dfef21f6c7b0bc6a356d6b9f41a3b3b98ae9
170+
container: ghcr.io/llvm/libcxx-linux-builder:b6bb9dc5abd7c6452c13a53fa8949cb259db459b
171171
steps:
172172
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
173173
- name: ${{ matrix.config }}

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2455,6 +2455,30 @@ void RewriteInstance::readDynamicRelocations(const SectionRef &Section,
24552455
if (Symbol)
24562456
SymbolIndex[Symbol] = getRelocationSymbol(InputFile, Rel);
24572457

2458+
const uint64_t ReferencedAddress = SymbolAddress + Addend;
2459+
BinaryFunction *Func =
2460+
BC->getBinaryFunctionContainingAddress(ReferencedAddress);
2461+
2462+
if (Relocation::isRelative(RType) && SymbolAddress == 0) {
2463+
if (Func) {
2464+
if (!Func->isInConstantIsland(ReferencedAddress)) {
2465+
if (const uint64_t ReferenceOffset =
2466+
ReferencedAddress - Func->getAddress()) {
2467+
Func->addEntryPointAtOffset(ReferenceOffset);
2468+
}
2469+
} else {
2470+
BC->errs() << "BOLT-ERROR: referenced address at 0x"
2471+
<< Twine::utohexstr(ReferencedAddress)
2472+
<< " is in constant island of function " << *Func << "\n";
2473+
exit(1);
2474+
}
2475+
}
2476+
} else if (Relocation::isRelative(RType) && SymbolAddress != 0) {
2477+
BC->errs() << "BOLT-ERROR: symbol address non zero for RELATIVE "
2478+
"relocation type\n";
2479+
exit(1);
2480+
}
2481+
24582482
BC->addDynamicRelocation(Rel.getOffset(), Symbol, RType, Addend);
24592483
}
24602484
}
@@ -5696,7 +5720,7 @@ uint64_t RewriteInstance::getNewFunctionOrDataAddress(uint64_t OldAddress) {
56965720
for (const BinaryBasicBlock &BB : *BF)
56975721
if (BB.isEntryPoint() &&
56985722
(BF->getAddress() + BB.getOffset()) == OldAddress)
5699-
return BF->getOutputAddress() + BB.getOffset();
5723+
return BB.getOutputStartAddress();
57005724
}
57015725
BC->errs() << "BOLT-ERROR: unable to get new address corresponding to "
57025726
"input address 0x"

bolt/lib/Target/AArch64/AArch64MCSymbolizer.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,39 @@ AArch64MCSymbolizer::adjustRelocation(const Relocation &Rel,
125125
// instruction pairs and will perform necessary adjustments.
126126
ErrorOr<uint64_t> SymbolValue = BC.getSymbolValue(*Rel.Symbol);
127127
assert(SymbolValue && "Symbol value should be set");
128-
(void)SymbolValue;
129-
130-
AdjustedRel.Symbol = BC.registerNameAtAddress("__BOLT_got_zero", 0, 0, 0);
131-
AdjustedRel.Addend = Rel.Value;
128+
const uint64_t SymbolPageAddr = *SymbolValue & ~0xfffULL;
129+
130+
// Check if defined symbol and GOT are on the same page. If they are not,
131+
// disambiguate the operand.
132+
if (BC.MIB->isADRP(Inst) && Rel.Addend == 0 &&
133+
SymbolPageAddr == Rel.Value &&
134+
!isPageAddressValidForGOT(SymbolPageAddr)) {
135+
AdjustedRel.Type = ELF::R_AARCH64_ADR_PREL_PG_HI21;
136+
} else {
137+
AdjustedRel.Symbol = BC.registerNameAtAddress("__BOLT_got_zero", 0, 0, 0);
138+
AdjustedRel.Addend = Rel.Value;
139+
}
132140
}
133141

134142
return AdjustedRel;
135143
}
136144

145+
bool AArch64MCSymbolizer::isPageAddressValidForGOT(uint64_t PageAddress) const {
146+
assert(!(PageAddress & 0xfffULL) && "Page address not aligned at 4KB");
147+
148+
ErrorOr<BinarySection &> GOT =
149+
Function.getBinaryContext().getUniqueSectionByName(".got");
150+
if (!GOT || !GOT->getSize())
151+
return false;
152+
153+
const uint64_t GOTFirstPageAddress = GOT->getAddress() & ~0xfffULL;
154+
const uint64_t GOTLastPageAddress =
155+
(GOT->getAddress() + GOT->getSize() - 1) & ~0xfffULL;
156+
157+
return PageAddress >= GOTFirstPageAddress &&
158+
PageAddress <= GOTLastPageAddress;
159+
}
160+
137161
void AArch64MCSymbolizer::tryAddingPcLoadReferenceComment(raw_ostream &CStream,
138162
int64_t Value,
139163
uint64_t Address) {}

bolt/lib/Target/AArch64/AArch64MCSymbolizer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class AArch64MCSymbolizer : public MCSymbolizer {
2828
std::optional<Relocation> adjustRelocation(const Relocation &Rel,
2929
const MCInst &Inst) const;
3030

31+
/// Return true if \p PageAddress is a valid page address for .got section.
32+
bool isPageAddressValidForGOT(uint64_t PageAddress) const;
33+
3134
public:
3235
AArch64MCSymbolizer(BinaryFunction &Function, bool CreateNewSymbols = true)
3336
: MCSymbolizer(*Function.getBinaryContext().Ctx.get(), nullptr),

bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
244244
Inst.clear();
245245
Inst.addOperand(MCOperand::createExpr(RISCVMCExpr::create(
246246
MCSymbolRefExpr::create(Target, MCSymbolRefExpr::VK_None, *Ctx),
247-
RISCVMCExpr::VK_RISCV_CALL, *Ctx)));
247+
RISCVMCExpr::VK_CALL, *Ctx)));
248248
}
249249

250250
void createCall(MCInst &Inst, const MCSymbol *Target,
@@ -434,19 +434,19 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
434434
case ELF::R_RISCV_TLS_GOT_HI20:
435435
// The GOT is reused so no need to create GOT relocations
436436
case ELF::R_RISCV_PCREL_HI20:
437-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_PCREL_HI, Ctx);
437+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_PCREL_HI, Ctx);
438438
case ELF::R_RISCV_PCREL_LO12_I:
439439
case ELF::R_RISCV_PCREL_LO12_S:
440-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_PCREL_LO, Ctx);
440+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_PCREL_LO, Ctx);
441441
case ELF::R_RISCV_HI20:
442-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_HI, Ctx);
442+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_HI, Ctx);
443443
case ELF::R_RISCV_LO12_I:
444444
case ELF::R_RISCV_LO12_S:
445-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_LO, Ctx);
445+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_LO, Ctx);
446446
case ELF::R_RISCV_CALL:
447-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_CALL, Ctx);
447+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_CALL, Ctx);
448448
case ELF::R_RISCV_CALL_PLT:
449-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_CALL_PLT, Ctx);
449+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_CALL_PLT, Ctx);
450450
}
451451
}
452452

@@ -471,8 +471,8 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
471471
switch (cast<RISCVMCExpr>(ImmExpr)->getKind()) {
472472
default:
473473
return false;
474-
case RISCVMCExpr::VK_RISCV_CALL:
475-
case RISCVMCExpr::VK_RISCV_CALL_PLT:
474+
case RISCVMCExpr::VK_CALL:
475+
case RISCVMCExpr::VK_CALL_PLT:
476476
return true;
477477
}
478478
}

bolt/test/AArch64/computed-goto.s

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// This test checks that BOLT creates entry points for addresses
2+
// referenced by dynamic relocations.
3+
// The test also checks that BOLT can map addresses inside functions.
4+
5+
// Checks for error and entry points.
6+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
7+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
8+
# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
9+
# RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg | FileCheck --check-prefix=CHECK-ENTRIES %s
10+
11+
// Checks for dynamic relocations.
12+
# RUN: llvm-readelf -dr %t.bolt > %t.out.txt
13+
# RUN: llvm-objdump -j .rela.dyn -d %t.bolt >> %t.out.txt
14+
# RUN: FileCheck --check-prefix=CHECK-RELOCS %s --input-file=%t.out.txt
15+
16+
// Before bolt could handle mapping addresses within moved functions, it
17+
// would bail out with an error of the form:
18+
// BOLT-ERROR: unable to get new address corresponding to input address 0x10390 in function main. Consider adding this function to --skip-funcs=...
19+
// These addresses arise if computed GOTO is in use.
20+
// Check that bolt does not emit any error.
21+
# CHECK-NOT: BOLT-ERROR
22+
23+
// Check that there are dynamic relocations.
24+
# CHECK-RELOCS: Dynamic section at offset {{.*}} contains {{.*}} entries:
25+
# CHECK-RELOCS: Relocation section '.rela.dyn' at offset {{.*}} contains {{.*}} entries
26+
27+
// Check that dynamic relocations were updated
28+
# CHECK-RELOCS: [[#%x,OFF:]] [[#%x,INFO_DYN:]] R_AARCH64_RELATIVE [[#%x,ADDR:]]
29+
# CHECK-RELOCS-NEXT: [[#OFF + 8]] {{0*}}[[#INFO_DYN]] R_AARCH64_RELATIVE [[#ADDR + 8]]
30+
# CHECK-RELOCS: [[#ADDR]] <unknown>
31+
# CHECK-RELOCS: [[#ADDR + 8]] <unknown>
32+
33+
// Check that BOLT registers extra entry points for dynamic relocations.
34+
# CHECK-ENTRIES: Binary Function "main" after building cfg {
35+
# CHECK-ENTRIES: IsMultiEntry: 1
36+
# CHECK-ENTRIES: .Ltmp0 {{.*}}
37+
# CHECK-ENTRIES-NEXT: Secondary Entry Point: {{.*}}
38+
# CHECK-ENTRIES: .Ltmp1 {{.*}}
39+
# CHECK-ENTRIES-NEXT: Secondary Entry Point: {{.*}}
40+
41+
.globl main
42+
.p2align 2
43+
.type main,@function
44+
main:
45+
.cfi_startproc
46+
adrp x8, .L__const.main.ptrs+8
47+
add x8, x8, :lo12:.L__const.main.ptrs+8
48+
ldr x9, [x8], #8
49+
br x9
50+
51+
.Label0: // Block address taken
52+
ldr x9, [x8], #8
53+
br x9
54+
55+
.Label1: // Block address taken
56+
mov w0, #42
57+
ret
58+
59+
.Lfunc_end0:
60+
.size main, .Lfunc_end0-main
61+
.cfi_endproc
62+
.type .L__const.main.ptrs,@object
63+
.section .data.rel.ro,"aw",@progbits
64+
.p2align 3, 0x0
65+
.L__const.main.ptrs:
66+
.xword .Label0
67+
.xword .Label1

0 commit comments

Comments
 (0)