Skip to content

Commit ef8e340

Browse files
committed
Merge from 'main' to 'sycl-web' (178 commits)
CONFLICT (content): Merge conflict in clang/include/clang/Basic/Attr.td CONFLICT (content): Merge conflict in clang/lib/CodeGen/CodeGenFunction.cpp CONFLICT (content): Merge conflict in clang/lib/Sema/SemaDeclAttr.cpp
2 parents fa665c4 + 297f0b3 commit ef8e340

File tree

660 files changed

+95570
-87792
lines changed

Some content is hidden

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

660 files changed

+95570
-87792
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 \

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/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
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
## Check that BOLT symbolizer properly handles loads from GOT, including
2+
## instruction sequences changed/relaxed by the linker.
3+
4+
# RUN: split-file %s %t
5+
6+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %t/main.s \
7+
# RUN: -o %t/main.o
8+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %t/near.s \
9+
# RUN: -o %t/near.o
10+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %t/far.s \
11+
# RUN: -o %t/far.o
12+
# RUN: %clang %cflags %t/main.o %t/near.o %t/far.o -o %t/main.exe -Wl,-q -static
13+
# RUN: llvm-bolt %t/main.exe -o %t/main.bolt --keep-nops --print-disasm \
14+
# RUN: --print-only=_start | FileCheck %s
15+
16+
#--- main.s
17+
18+
.text
19+
.globl _start
20+
.p2align 2
21+
.type _start, @function
22+
# CHECK-LABEL: _start
23+
_start:
24+
25+
## Function address load relaxable into nop+adr.
26+
# CHECK: nop
27+
# CHECK-NEXT: adr x0, near
28+
adrp x0, :got:near
29+
ldr x0, [x0, :got_lo12:near]
30+
31+
## Function address load relaxable into adrp+add.
32+
# CHECK-NEXT: adrp x1, far
33+
# CHECK-NEXT: add x1, x1, :lo12:far
34+
adrp x1, :got:far
35+
ldr x1, [x1, :got_lo12:far]
36+
37+
## Non-relaxable due to the instruction in-between.
38+
# CHECK-NEXT: adrp x2, __BOLT_got_zero
39+
# CHECK-NEXT: nop
40+
# CHECK-NEXT: ldr x2, [x2, :lo12:__BOLT_got_zero{{.*}}]
41+
adrp x2, :got:near
42+
nop
43+
ldr x2, [x2, :got_lo12:near]
44+
45+
## Load data object with local visibility. Relaxable into adrp+add.
46+
# CHECK-NEXT: adrp x3, "local_far_data/1"
47+
# CHECK-NEXT: add x3, x3, :lo12:"local_far_data/1"
48+
adrp x3, :got:local_far_data
49+
ldr x3, [x3, :got_lo12:local_far_data]
50+
51+
## Global data reference relaxable into adrp+add.
52+
# CHECK-NEXT: adrp x4, far_data
53+
# CHECK-NEXT: add x4, x4, :lo12:far_data
54+
adrp x4, :got:far_data
55+
ldr x4, [x4, :got_lo12:far_data]
56+
57+
ret
58+
.size _start, .-_start
59+
60+
.weak near
61+
.weak far
62+
.weak far_data
63+
64+
## Data object separated by more than 1MB from _start.
65+
.data
66+
.type local_far_data, @object
67+
local_far_data:
68+
.xword 0
69+
.size local_far_data, .-local_far_data
70+
71+
#--- near.s
72+
73+
.text
74+
.globl near
75+
.type near, @function
76+
near:
77+
ret
78+
.size near, .-near
79+
80+
#--- far.s
81+
82+
.text
83+
84+
## Insert 1MB of empty space to make objects after it unreachable by adr
85+
## instructions in _start.
86+
.space 0x100000
87+
88+
.globl far
89+
.type far, @function
90+
far:
91+
ret
92+
.size far, .-far
93+
94+
.data
95+
.globl far_data
96+
.type far_data, @object
97+
far_data:
98+
.xword 0
99+
.size far_data, .-far_data
100+

bolt/test/X86/Inputs/indirect_goto.c renamed to bolt/test/Inputs/indirect_goto.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
int main(int argc, char *argv[]) {
2-
static const void *T1[] = { &&L1, &&L2 };
3-
static const void *T2[] = { &&L2, &&L3 };
2+
static const void *T1[] = {&&L1, &&L2};
3+
static const void *T2[] = {&&L2, &&L3};
44

55
const void **T = (argc > 1) ? T1 : T2;
66

0 commit comments

Comments
 (0)