Skip to content

Commit 44a7752

Browse files
committed
merge main into amd-stg-open
reverts: [X86][AVX10] Permit AVX512 options/features used together with AVX10 (llvm#71318) breaks pgmath build Change-Id: I14334b22129122d0aa04076dc992d45cf344f6c7
2 parents cac4eea + aa2376a commit 44a7752

File tree

276 files changed

+18554
-1333
lines changed

Some content is hidden

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

276 files changed

+18554
-1333
lines changed

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ class RewriteInstance {
430430

431431
/// Common section names.
432432
static StringRef getEHFrameSectionName() { return ".eh_frame"; }
433+
static StringRef getRelaDynSectionName() { return ".rela.dyn"; }
433434

434435
/// An instance of the input binary we are processing, externally owned.
435436
llvm::object::ELFObjectFileBase *InputFile;

bolt/lib/Passes/ADRRelaxationPass.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
5656
continue;
5757
}
5858

59-
BinaryFunction *TargetBF = BC.getFunctionForSymbol(Symbol);
60-
if (TargetBF && TargetBF == &BF)
61-
continue;
59+
// Don't relax adr if it points to the same function and it is not split
60+
// and BF initial size is < 1MB.
61+
const unsigned OneMB = 0x100000;
62+
if (!BF.isSplit() && BF.getSize() < OneMB) {
63+
BinaryFunction *TargetBF = BC.getFunctionForSymbol(Symbol);
64+
if (TargetBF && TargetBF == &BF)
65+
continue;
66+
}
6267

6368
MCPhysReg Reg;
6469
BC.MIB->getADRReg(Inst, Reg);
@@ -72,14 +77,17 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
7277

7378
if (It != BB.begin() && BC.MIB->isNoop(*std::prev(It))) {
7479
It = BB.eraseInstruction(std::prev(It));
75-
} else if (opts::StrictMode && !BF.isSimple()) {
80+
} else if (std::next(It) != BB.end() && BC.MIB->isNoop(*std::next(It))) {
81+
BB.eraseInstruction(std::next(It));
82+
} else if (!opts::StrictMode && !BF.isSimple()) {
7683
// If the function is not simple, it may contain a jump table undetected
7784
// by us. This jump table may use an offset from the branch instruction
7885
// to land in the desired place. If we add new instructions, we
7986
// invalidate this offset, so we have to rely on linker-inserted NOP to
8087
// replace it with ADRP, and abort if it is not present.
88+
auto L = BC.scopeLock();
8189
errs() << formatv("BOLT-ERROR: Cannot relax adr in non-simple function "
82-
"{0}. Can't proceed in current mode.\n",
90+
"{0}. Use --strict option to override\n",
8391
BF.getOneName());
8492
PassFailed = true;
8593
return;

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,19 @@ void RewriteInstance::processDynamicRelocations() {
22172217
}
22182218

22192219
// The rest of dynamic relocations - DT_RELA.
2220+
// The static executable might have .rela.dyn secion and not have PT_DYNAMIC
2221+
if (!DynamicRelocationsSize && BC->IsStaticExecutable) {
2222+
ErrorOr<BinarySection &> DynamicRelSectionOrErr =
2223+
BC->getUniqueSectionByName(getRelaDynSectionName());
2224+
if (DynamicRelSectionOrErr) {
2225+
DynamicRelocationsAddress = DynamicRelSectionOrErr->getAddress();
2226+
DynamicRelocationsSize = DynamicRelSectionOrErr->getSize();
2227+
const SectionRef &SectionRef = DynamicRelSectionOrErr->getSectionRef();
2228+
DynamicRelativeRelocationsCount = std::distance(
2229+
SectionRef.relocation_begin(), SectionRef.relocation_end());
2230+
}
2231+
}
2232+
22202233
if (DynamicRelocationsSize > 0) {
22212234
ErrorOr<BinarySection &> DynamicRelSectionOrErr =
22222235
BC->getSectionForAddress(*DynamicRelocationsAddress);

bolt/test/AArch64/ifunc.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77
// RUN: llvm-bolt %t.O0.exe -o %t.O0.bolt.exe \
88
// RUN: --print-disasm --print-only=_start | \
99
// RUN: FileCheck --check-prefix=O0_CHECK %s
10+
// RUN: llvm-readelf -aW %t.O0.bolt.exe | \
11+
// RUN: FileCheck --check-prefix=REL_CHECK %s
12+
13+
// Non-pie static executable doesn't generate PT_DYNAMIC, check relocation
14+
// is readed successfully and IPLT trampoline has been identified by bolt.
15+
// RUN: %clang %cflags -nostdlib -O3 %s -fuse-ld=lld -no-pie \
16+
// RUN: -o %t.O3_nopie.exe -Wl,-q
17+
// RUN: llvm-readelf -l %t.O3_nopie.exe | \
18+
// RUN: FileCheck --check-prefix=NON_DYN_CHECK %s
19+
// RUN: llvm-bolt %t.O3_nopie.exe -o %t.O3_nopie.bolt.exe \
20+
// RUN: --print-disasm --print-only=_start | \
21+
// RUN: FileCheck --check-prefix=O3_CHECK %s
22+
// RUN: llvm-readelf -aW %t.O3_nopie.bolt.exe | \
23+
// RUN: FileCheck --check-prefix=REL_CHECK %s
1024

1125
// With -O3 direct call is performed on IPLT trampoline. IPLT trampoline
1226
// doesn't have associated symbol. The ifunc symbol has the same address as
@@ -16,6 +30,8 @@
1630
// RUN: llvm-bolt %t.O3_pie.exe -o %t.O3_pie.bolt.exe \
1731
// RUN: --print-disasm --print-only=_start | \
1832
// RUN: FileCheck --check-prefix=O3_CHECK %s
33+
// RUN: llvm-readelf -aW %t.O3_pie.bolt.exe | \
34+
// RUN: FileCheck --check-prefix=REL_CHECK %s
1935

2036
// Check that IPLT trampoline located in .plt section are normally handled by
2137
// BOLT. The gnu-ld linker doesn't use separate .iplt section.
@@ -24,10 +40,17 @@
2440
// RUN: llvm-bolt %t.iplt_O3_pie.exe -o %t.iplt_O3_pie.bolt.exe \
2541
// RUN: --print-disasm --print-only=_start | \
2642
// RUN: FileCheck --check-prefix=O3_CHECK %s
43+
// RUN: llvm-readelf -aW %t.iplt_O3_pie.bolt.exe | \
44+
// RUN: FileCheck --check-prefix=REL_CHECK %s
45+
46+
// NON_DYN_CHECK-NOT: DYNAMIC
2747

2848
// O0_CHECK: adr x{{[0-9]+}}, ifoo
2949
// O3_CHECK: b "{{resolver_foo|ifoo}}{{.*}}@PLT"
3050

51+
// REL_CHECK: R_AARCH64_IRELATIVE [[#%x,REL_SYMB_ADDR:]]
52+
// REL_CHECK: [[#REL_SYMB_ADDR]] {{.*}} FUNC {{.*}} resolver_foo
53+
3154
static void foo() {}
3255

3356
static void *resolver_foo(void) { return foo; }

bolt/test/AArch64/r_aarch64_prelxx.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// CHECKPREL-NEXT: R_AARCH64_PREL32 {{.*}} _start + 4
1313
// CHECKPREL-NEXT: R_AARCH64_PREL64 {{.*}} _start + 8
1414

15-
// RUN: llvm-bolt %t.exe -o %t.bolt
15+
// RUN: llvm-bolt %t.exe -o %t.bolt --strict
1616
// RUN: llvm-objdump -D %t.bolt | FileCheck %s --check-prefix=CHECKPREL32
1717

1818
// CHECKPREL32: [[#%x,DATATABLEADDR:]] <datatable>:
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
11
# The second and third ADR instructions are non-local to functions
22
# and must be replaced with ADRP + ADD by BOLT
3-
# Also since main is non-simple, we can't change it's length so we have to
4-
# replace NOP with adrp, and if there is no nop before adr in non-simple
3+
# Also since main and test are non-simple, we can't change it's length so we
4+
# have to replace NOP with adrp, and if there is no nop before adr in non-simple
55
# function, we can't guarantee we didn't break possible jump tables, so we
6-
# fail in strict mode
6+
# fail in non-strict mode
77

88
# REQUIRES: system-linux
99

1010
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
1111
# RUN: %s -o %t.o
1212
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
13-
# RUN: llvm-bolt %t.exe -o %t.bolt --adr-relaxation=true
13+
# RUN: llvm-bolt %t.exe -o %t.bolt --adr-relaxation=true --strict
1414
# RUN: llvm-objdump --no-print-imm-hex -d --disassemble-symbols=main %t.bolt | FileCheck %s
1515
# RUN: %t.bolt
16-
# RUN: not llvm-bolt %t.exe -o %t.bolt --adr-relaxation=true --strict \
16+
# RUN: not llvm-bolt %t.exe -o %t.bolt --adr-relaxation=true \
1717
# RUN: 2>&1 | FileCheck %s --check-prefix CHECK-ERROR
1818

19-
.data
20-
.align 8
21-
.global Gvar
22-
Gvar: .xword 0x0
23-
.global Gvar2
24-
Gvar2: .xword 0x42
25-
2619
.text
2720
.align 4
2821
.global test
2922
.type test, %function
3023
test:
24+
adr x2, Gvar
3125
mov x0, xzr
3226
ret
3327
.size test, .-test
@@ -47,11 +41,22 @@ br:
4741
.CI:
4842
.word 0xff
4943

44+
.data
45+
.align 8
46+
.global Gvar
47+
Gvar: .xword 0x0
48+
.global Gvar2
49+
Gvar2: .xword 0x42
50+
.balign 4
51+
jmptable:
52+
.word 0
53+
.word test - jmptable
54+
5055
# CHECK: <main>:
5156
# CHECK-NEXT: adr x0, 0x{{[1-8a-f][0-9a-f]*}}
5257
# CHECK-NEXT: adrp x1, 0x{{[1-8a-f][0-9a-f]*}}
5358
# CHECK-NEXT: add x1, x1, #{{[1-8a-f][0-9a-f]*}}
5459
# CHECK-NEXT: adrp x2, 0x{{[1-8a-f][0-9a-f]*}}
5560
# CHECK-NEXT: add x2, x2, #{{[1-8a-f][0-9a-f]*}}
5661
# CHECK-NEXT: adr x3, 0x{{[1-8a-f][0-9a-f]*}}
57-
# CHECK-ERROR: BOLT-ERROR: Cannot relax adr in non-simple function main
62+
# CHECK-ERROR: BOLT-ERROR: Cannot relax adr in non-simple function

bolt/test/runtime/AArch64/controlflow.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ test_cond_branch:
4848
.global test_branch_reg
4949
.type test_branch_reg, %function
5050
test_branch_reg:
51+
nop
5152
adr x0, test_branch_zero
5253
br x0
5354
panic
@@ -97,6 +98,7 @@ test_call:
9798
.global test_call_reg
9899
.type test_call_reg, %function
99100
test_call_reg:
101+
nop
100102
adr x0, test_call_foo
101103
blr x0
102104
panic

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,13 @@ void IncludeSorter::addInclude(StringRef FileName, bool IsAngled,
134134
int Offset = findNextLine(SourceMgr->getCharacterData(EndLocation));
135135

136136
// Record the relevant location information for this inclusion directive.
137-
IncludeLocations[FileName].push_back(
137+
auto &IncludeLocation = IncludeLocations[FileName];
138+
IncludeLocation.push_back(
138139
SourceRange(HashLocation, EndLocation.getLocWithOffset(Offset)));
139-
SourceLocations.push_back(IncludeLocations[FileName].back());
140+
SourceLocations.push_back(IncludeLocation.back());
140141

141142
// Stop if this inclusion is a duplicate.
142-
if (IncludeLocations[FileName].size() > 1)
143+
if (IncludeLocation.size() > 1)
143144
return;
144145

145146
// Add the included file's name to the appropriate bucket.

clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ add_clang_library(clangDaemonTweaks OBJECT
2727
PopulateSwitch.cpp
2828
RawStringLiteral.cpp
2929
RemoveUsingNamespace.cpp
30+
ScopifyEnum.cpp
3031
SpecialMembers.cpp
3132
SwapIfBranches.cpp
3233

0 commit comments

Comments
 (0)