Skip to content

Commit f7c9407

Browse files
Merge branch 'main' into zero-init3
2 parents a58bb99 + 437834e commit f7c9407

File tree

489 files changed

+13500
-4514
lines changed

Some content is hidden

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

489 files changed

+13500
-4514
lines changed

bolt/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ if (BOLT_ENABLE_RUNTIME)
163163
add_llvm_install_targets(install-bolt_rt
164164
DEPENDS bolt_rt bolt
165165
COMPONENT bolt)
166-
set(LIBBOLT_RT_INSTR "${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/lib/libbolt_rt_instr.a")
167-
set(LIBBOLT_RT_HUGIFY "${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/lib/libbolt_rt_hugify.a")
166+
set(LIBBOLT_RT_INSTR "${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/lib${LLVM_LIBDIR_SUFFIX}/libbolt_rt_instr.a")
167+
set(LIBBOLT_RT_HUGIFY "${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/lib${LLVM_LIBDIR_SUFFIX}/libbolt_rt_hugify.a")
168168
endif()
169169

170170
find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.bfd ld.bfd DOC "GNU ld")

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,12 @@ class BinaryContext {
13631363
if (std::optional<uint32_t> Size = MIB->getSize(Inst))
13641364
return *Size;
13651365

1366+
if (MIB->isPseudo(Inst))
1367+
return 0;
1368+
1369+
if (std::optional<uint32_t> Size = MIB->getInstructionSize(Inst))
1370+
return *Size;
1371+
13661372
if (!Emitter)
13671373
Emitter = this->MCE.get();
13681374
SmallString<256> Code;

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,11 @@ class MCPlusBuilder {
12041204
/// Get instruction size specified via annotation.
12051205
std::optional<uint32_t> getSize(const MCInst &Inst) const;
12061206

1207+
/// Get target-specific instruction size.
1208+
virtual std::optional<uint32_t> getInstructionSize(const MCInst &Inst) const {
1209+
return std::nullopt;
1210+
}
1211+
12071212
/// Set instruction size.
12081213
void setSize(MCInst &Inst, uint32_t Size) const;
12091214

bolt/lib/Passes/Inliner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,13 @@ Inliner::inlineCall(BinaryBasicBlock &CallerBB,
310310
if (MIB.isPseudo(Inst))
311311
continue;
312312

313-
MIB.stripAnnotations(Inst, /*KeepTC=*/BC.isX86());
313+
MIB.stripAnnotations(Inst, /*KeepTC=*/BC.isX86() || BC.isAArch64());
314314

315315
// Fix branch target. Strictly speaking, we don't have to do this as
316316
// targets of direct branches will be fixed later and don't matter
317317
// in the CFG state. However, disassembly may look misleading, and
318318
// hence we do the fixing.
319-
if (MIB.isBranch(Inst)) {
319+
if (MIB.isBranch(Inst) && !MIB.isTailCall(Inst)) {
320320
assert(!MIB.isIndirectBranch(Inst) &&
321321
"unexpected indirect branch in callee");
322322
const BinaryBasicBlock *TargetBB =

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,36 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
133133
public:
134134
using MCPlusBuilder::MCPlusBuilder;
135135

136+
MCPhysReg getStackPointer() const override { return AArch64::SP; }
137+
138+
bool isPush(const MCInst &Inst) const override { return false; }
139+
140+
bool isPop(const MCInst &Inst) const override { return false; }
141+
142+
void createCall(MCInst &Inst, const MCSymbol *Target,
143+
MCContext *Ctx) override {
144+
createDirectCall(Inst, Target, Ctx, false);
145+
}
146+
147+
bool convertTailCallToCall(MCInst &Inst) override {
148+
int NewOpcode;
149+
switch (Inst.getOpcode()) {
150+
default:
151+
return false;
152+
case AArch64::B:
153+
NewOpcode = AArch64::BL;
154+
break;
155+
case AArch64::BR:
156+
NewOpcode = AArch64::BLR;
157+
break;
158+
}
159+
160+
Inst.setOpcode(NewOpcode);
161+
removeAnnotation(Inst, MCPlus::MCAnnotation::kTailCall);
162+
clearOffset(Inst);
163+
return true;
164+
}
165+
136166
bool equals(const MCTargetExpr &A, const MCTargetExpr &B,
137167
CompFuncTy Comp) const override {
138168
const auto &AArch64ExprA = cast<AArch64MCExpr>(A);
@@ -1792,6 +1822,11 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
17921822
}
17931823

17941824
uint16_t getMinFunctionAlignment() const override { return 4; }
1825+
1826+
std::optional<uint32_t>
1827+
getInstructionSize(const MCInst &Inst) const override {
1828+
return 4;
1829+
}
17951830
};
17961831

17971832
} // end anonymous namespace

bolt/runtime/CMakeLists.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ add_library(bolt_rt_instr STATIC
1616
instr.cpp
1717
${CMAKE_CURRENT_BINARY_DIR}/config.h
1818
)
19-
set_target_properties(bolt_rt_instr PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
19+
set_target_properties(bolt_rt_instr PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
2020
add_library(bolt_rt_hugify STATIC
2121
hugify.cpp
2222
${CMAKE_CURRENT_BINARY_DIR}/config.h
2323
)
24-
set_target_properties(bolt_rt_hugify PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
24+
set_target_properties(bolt_rt_hugify PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
2525

2626
if(NOT BOLT_BUILT_STANDALONE)
2727
add_custom_command(TARGET bolt_rt_instr POST_BUILD
28-
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib/libbolt_rt_instr.a" "${LLVM_LIBRARY_DIR}")
28+
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libbolt_rt_instr.a" "${LLVM_LIBRARY_DIR}")
2929
add_custom_command(TARGET bolt_rt_hugify POST_BUILD
30-
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib/libbolt_rt_hugify.a" "${LLVM_LIBRARY_DIR}")
30+
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libbolt_rt_hugify.a" "${LLVM_LIBRARY_DIR}")
3131
endif()
3232

3333
set(BOLT_RT_FLAGS
@@ -53,23 +53,23 @@ target_include_directories(bolt_rt_instr PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
5353
target_compile_options(bolt_rt_hugify PRIVATE ${BOLT_RT_FLAGS})
5454
target_include_directories(bolt_rt_hugify PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
5555

56-
install(TARGETS bolt_rt_instr DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
57-
install(TARGETS bolt_rt_hugify DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
56+
install(TARGETS bolt_rt_instr DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
57+
install(TARGETS bolt_rt_hugify DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
5858

5959
if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*" AND CMAKE_SYSTEM_NAME STREQUAL "Darwin")
6060
add_library(bolt_rt_instr_osx STATIC
6161
instr.cpp
6262
${CMAKE_CURRENT_BINARY_DIR}/config.h
6363
)
64-
set_target_properties(bolt_rt_instr_osx PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
64+
set_target_properties(bolt_rt_instr_osx PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
6565
target_include_directories(bolt_rt_instr_osx PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
6666
target_compile_options(bolt_rt_instr_osx PRIVATE
6767
-target x86_64-apple-darwin19.6.0
6868
${BOLT_RT_FLAGS})
69-
install(TARGETS bolt_rt_instr_osx DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
69+
install(TARGETS bolt_rt_instr_osx DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
7070

7171
if(NOT BOLT_BUILT_STANDALONE)
7272
add_custom_command(TARGET bolt_rt_instr_osx POST_BUILD
73-
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib/libbolt_rt_instr_osx.a" "${LLVM_LIBRARY_DIR}")
73+
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libbolt_rt_instr_osx.a" "${LLVM_LIBRARY_DIR}")
7474
endif()
7575
endif()
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## This test checks that inline is properly handled by BOLT on aarch64.
2+
3+
# REQUIRES: system-linux
4+
5+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
6+
# RUN: %clang %cflags -O0 %t.o -o %t.exe -Wl,-q
7+
# RUN: llvm-bolt --inline-small-functions --print-inline --print-only=_Z3barP1A \
8+
# RUN: %t.exe -o %t.bolt | FileCheck %s
9+
10+
# CHECK: BOLT-INFO: inlined 0 calls at 1 call sites in 2 iteration(s). Change in binary size: 4 bytes.
11+
# CHECK: Binary Function "_Z3barP1A" after inlining {
12+
# CHECK-NOT: bl _Z3fooP1A
13+
# CHECK: ldr x8, [x0]
14+
# CHECK-NEXT: ldr w0, [x8]
15+
16+
.text
17+
.globl _Z3fooP1A
18+
.type _Z3fooP1A,@function
19+
_Z3fooP1A:
20+
ldr x8, [x0]
21+
ldr w0, [x8]
22+
ret
23+
.size _Z3fooP1A, .-_Z3fooP1A
24+
25+
.globl _Z3barP1A
26+
.type _Z3barP1A,@function
27+
_Z3barP1A:
28+
stp x29, x30, [sp, #-16]!
29+
mov x29, sp
30+
bl _Z3fooP1A
31+
mul w0, w0, w0
32+
ldp x29, x30, [sp], #16
33+
ret
34+
.size _Z3barP1A, .-_Z3barP1A
35+
36+
.globl main
37+
.p2align 2
38+
.type main,@function
39+
main:
40+
mov w0, wzr
41+
ret
42+
.size main, .-main
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## This test checks that inline is properly handled by BOLT on aarch64.
2+
3+
# REQUIRES: system-linux
4+
5+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
6+
# RUN: %clang %cflags -O0 %t.o -o %t.exe -Wl,-q
7+
# RUN: llvm-bolt --inline-small-functions --print-inline --print-only=test \
8+
# RUN: %t.exe -o %t.bolt | FileCheck %s
9+
10+
#CHECK: BOLT-INFO: inlined 0 calls at 1 call sites in 2 iteration(s). Change in binary size: 4 bytes.
11+
#CHECK: Binary Function "test" after inlining {
12+
#CHECK-NOT: bl indirect
13+
#CHECK: add w0, w1, w0
14+
#CHECK-NEXT: blr x2
15+
16+
.text
17+
.globl indirect
18+
.type indirect,@function
19+
indirect:
20+
add w0, w1, w0
21+
br x2
22+
.size indirect, .-indirect
23+
24+
.globl test
25+
.type test,@function
26+
test:
27+
stp x29, x30, [sp, #-32]!
28+
stp x20, x19, [sp, #16]
29+
mov x29, sp
30+
mov w19, w1
31+
mov w20, w0
32+
bl indirect
33+
add w8, w19, w20
34+
cmp w0, #0
35+
csinc w0, w8, wzr, eq
36+
ldp x20, x19, [sp, #16]
37+
ldp x29, x30, [sp], #32
38+
ret
39+
.size test, .-test
40+
41+
.globl main
42+
.type main,@function
43+
main:
44+
mov w0, wzr
45+
ret
46+
.size main, .-main
47+
48+

bolt/test/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
host_linux_triple = config.target_triple.split("-")[0] + "-unknown-linux-gnu"
2-
common_linker_flags = "-fuse-ld=lld -Wl,--unresolved-symbols=ignore-all -pie"
2+
common_linker_flags = "-fuse-ld=lld -Wl,--unresolved-symbols=ignore-all -Wl,--build-id=none -pie"
33
flags = f"--target={host_linux_triple} -fPIE {common_linker_flags}"
44

55
config.substitutions.insert(0, ("%cflags", f"%cflags {flags}"))

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ C++23 Feature Support
316316
C++20 Feature Support
317317
^^^^^^^^^^^^^^^^^^^^^
318318

319+
- Implemented module level lookup for C++20 modules. (#GH90154)
320+
319321

320322
Resolutions to C++ Defect Reports
321323
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -787,6 +789,7 @@ Improvements to Clang's diagnostics
787789
scope.Unlock();
788790
require(scope); // Warning! Requires mu1.
789791
}
792+
- Diagnose invalid declarators in the declaration of constructors and destructors (#GH121706).
790793

791794
Improvements to Clang's time-trace
792795
----------------------------------
@@ -952,6 +955,8 @@ Bug Fixes to C++ Support
952955
- Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (#GH121274)
953956
- Fixed a crash caused by the incorrect construction of template arguments for CTAD alias guides when type
954957
constraints are applied. (#GH122134)
958+
- Fixed canonicalization of pack indexing types - Clang did not always recognized identical pack indexing. (#GH123033)
959+
955960

956961
Bug Fixes to AST Handling
957962
^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)