Skip to content

Commit b27b523

Browse files
committed
merge main into amd-staging
2 parents e1d745b + eb77061 commit b27b523

File tree

951 files changed

+40868
-28467
lines changed

Some content is hidden

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

951 files changed

+40868
-28467
lines changed

.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/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

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

bolt/test/X86/indirect-goto-pie.test

Lines changed: 0 additions & 16 deletions
This file was deleted.

bolt/test/X86/indirect-goto.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Check llvm-bolt processes binaries compiled from sources that use indirect goto.
2-
RUN: %clang %cflags -no-pie %S/Inputs/indirect_goto.c -Wl,-q -o %t
2+
RUN: %clang %cflags -no-pie %S/../Inputs/indirect_goto.c -Wl,-q -o %t
33
RUN: llvm-bolt %t -o %t.null --relocs=1 --print-cfg --print-only=main \
44
RUN: --strict \
55
RUN: 2>&1 | FileCheck %s

bolt/test/indirect-goto-relocs.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// This test checks that BOLT creates entry points from sources
2+
// that use indirect goto.
3+
4+
RUN: %clang %cflags -pie %S/Inputs/indirect_goto.c -o %t.exe -Wl,-q
5+
RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg | FileCheck --check-prefix=CHECK-PIE %s
6+
7+
RUN: %clang %cflags -no-pie %S/Inputs/indirect_goto.c -o %t.exe -Wl,-q
8+
RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg | FileCheck --check-prefix=CHECK-NO-PIE %s
9+
10+
// Check that BOLT registers extra entry points for dynamic relocations with PIE.
11+
CHECK-PIE: Binary Function "main" after building cfg {
12+
CHECK-PIE: IsMultiEntry: 1
13+
CHECK-PIE: Secondary Entry Points : {{.*}}
14+
15+
// Check that BOLT does not register extra entry points for dynamic relocations
16+
// without PIE
17+
CHECK-NO-PIE: Binary Function "main" after building cfg {
18+
CHECK-NO-PIE-NOT: IsMultiEntry: 1
19+
CHECK-NO-PIE-NOT: Secondary Entry Points : {{.*}}

clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ void SingleWorkItemBarrierCheck::check(const MatchFinder::MatchResult &Result) {
5454
bool IsNDRange = false;
5555
if (MatchedDecl->hasAttr<ReqdWorkGroupSizeAttr>()) {
5656
const auto *Attribute = MatchedDecl->getAttr<ReqdWorkGroupSizeAttr>();
57-
if (Attribute->getXDim() > 1 || Attribute->getYDim() > 1 ||
58-
Attribute->getZDim() > 1)
57+
auto Eval = [&](Expr *E) {
58+
return E->EvaluateKnownConstInt(MatchedDecl->getASTContext())
59+
.getExtValue();
60+
};
61+
if (Eval(Attribute->getXDim()) > 1 || Eval(Attribute->getYDim()) > 1 ||
62+
Eval(Attribute->getZDim()) > 1)
5963
IsNDRange = true;
6064
}
6165
if (IsNDRange) // No warning if kernel is treated as an NDRange.

clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ void ComparePointerToMemberVirtualFunctionCheck::check(
7070
// compare with variable which type is pointer to member function.
7171
llvm::SmallVector<SourceLocation, 12U> SameSignatureVirtualMethods{};
7272
const auto *MPT = cast<MemberPointerType>(DRE->getType().getCanonicalType());
73-
const Type *T = MPT->getClass();
74-
if (T == nullptr)
75-
return;
76-
const CXXRecordDecl *RD = T->getAsCXXRecordDecl();
73+
const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl();
7774
if (RD == nullptr)
7875
return;
7976

clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ bool isQualificationConvertiblePointer(QualType From, QualType To,
219219

220220
if (P1->isMemberPointerType())
221221
return P2->isMemberPointerType() &&
222-
P1->getAs<MemberPointerType>()->getClass() ==
223-
P2->getAs<MemberPointerType>()->getClass();
222+
P1->getAs<MemberPointerType>()->getMostRecentCXXRecordDecl() ==
223+
P2->getAs<MemberPointerType>()->getMostRecentCXXRecordDecl();
224224

225225
if (P1->isConstantArrayType())
226226
return P2->isConstantArrayType() &&

0 commit comments

Comments
 (0)