Skip to content

Commit 420bd67

Browse files
Merge branch 'main' into main
2 parents 5f68f29 + 49516ba commit 420bd67

File tree

2,136 files changed

+43791
-138581
lines changed

Some content is hidden

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

2,136 files changed

+43791
-138581
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,11 +1869,31 @@ class MCPlusBuilder {
18691869
llvm_unreachable("not implemented");
18701870
}
18711871

1872+
/// Check if an Instruction is a BTI landing pad with the required properties.
1873+
/// Takes both explicit and implicit BTIs into account.
1874+
virtual bool isBTILandingPad(MCInst &Inst, bool CallTarget,
1875+
bool JumpTarget) const {
1876+
llvm_unreachable("not implemented");
1877+
return false;
1878+
}
1879+
1880+
/// Check if an Instruction is an implicit BTI c landing pad.
1881+
virtual bool isImplicitBTIC(MCInst &Inst) const {
1882+
llvm_unreachable("not implemented");
1883+
return false;
1884+
}
1885+
18721886
/// Create a BTI landing pad instruction.
18731887
virtual void createBTI(MCInst &Inst, bool CallTarget, bool JumpTarget) const {
18741888
llvm_unreachable("not implemented");
18751889
}
18761890

1891+
/// Update operand of BTI instruction.
1892+
virtual void updateBTIVariant(MCInst &Inst, bool CallTarget,
1893+
bool JumpTarget) const {
1894+
llvm_unreachable("not implemented");
1895+
}
1896+
18771897
/// Store \p Target absolute address to \p RegName
18781898
virtual InstructionListType materializeAddress(const MCSymbol *Target,
18791899
MCContext *Ctx,

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,32 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
27822782
Inst.addOperand(MCOperand::createImm(HintNum));
27832783
}
27842784

2785+
bool isBTILandingPad(MCInst &Inst, bool CallTarget,
2786+
bool JumpTarget) const override {
2787+
unsigned HintNum = getBTIHintNum(CallTarget, JumpTarget);
2788+
bool IsExplicitBTI =
2789+
Inst.getOpcode() == AArch64::HINT && Inst.getNumOperands() == 1 &&
2790+
Inst.getOperand(0).isImm() && Inst.getOperand(0).getImm() == HintNum;
2791+
2792+
bool IsImplicitBTI = HintNum == 34 && isImplicitBTIC(Inst);
2793+
return IsExplicitBTI || IsImplicitBTI;
2794+
}
2795+
2796+
bool isImplicitBTIC(MCInst &Inst) const override {
2797+
// PACI[AB]SP are always implicitly BTI C, independently of
2798+
// SCTLR_EL1.BT[01].
2799+
return Inst.getOpcode() == AArch64::PACIASP ||
2800+
Inst.getOpcode() == AArch64::PACIBSP;
2801+
}
2802+
2803+
void updateBTIVariant(MCInst &Inst, bool CallTarget,
2804+
bool JumpTarget) const override {
2805+
assert(Inst.getOpcode() == AArch64::HINT && "Not a BTI instruction.");
2806+
unsigned HintNum = getBTIHintNum(CallTarget, JumpTarget);
2807+
Inst.clear();
2808+
Inst.addOperand(MCOperand::createImm(HintNum));
2809+
}
2810+
27852811
InstructionListType materializeAddress(const MCSymbol *Target, MCContext *Ctx,
27862812
MCPhysReg RegName,
27872813
int64_t Addend = 0) const override {

bolt/test/X86/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
if not "X86" in config.root.targets:
22
config.unsupported = True
33

4-
flags = "--target=x86_64-unknown-linux-gnu -nostdlib"
4+
flags = "--target=x86_64-unknown-linux-gnu -nostdlib -mllvm -x86-asm-syntax=att"
55

66
config.substitutions.insert(0, ("%cflags", f"%cflags {flags}"))
77
config.substitutions.insert(0, ("%cxxflags", f"%cxxflags {flags}"))

bolt/test/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if not "linux" in host_triple:
55
host_triple = host_triple.split("-")[0] + "-unknown-linux-gnu"
66

77
common_linker_flags = "-fuse-ld=lld -Wl,--unresolved-symbols=ignore-all -Wl,--build-id=none -pie"
8-
flags = f"--target={host_triple} -fPIE {common_linker_flags} -mllvm -x86-asm-syntax=att"
8+
flags = f"--target={host_triple} -fPIE {common_linker_flags}"
99

1010
config.substitutions.insert(0, ("%cflags", f"%cflags {flags}"))
1111
config.substitutions.insert(0, ("%cxxflags", f"%cxxflags {flags}"))

bolt/unittests/Core/MCPlusBuilder.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,22 +155,47 @@ TEST_P(MCPlusBuilderTester, AArch64_BTI) {
155155
auto II = BB->begin();
156156
ASSERT_EQ(II->getOpcode(), AArch64::HINT);
157157
ASSERT_EQ(II->getOperand(0).getImm(), 38);
158+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, true));
159+
BC->MIB->updateBTIVariant(*II, true, false);
160+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, false));
158161

159162
MCInst BTIj;
160163
BC->MIB->createBTI(BTIj, false, true);
161164
II = BB->addInstruction(BTIj);
162165
ASSERT_EQ(II->getOpcode(), AArch64::HINT);
163166
ASSERT_EQ(II->getOperand(0).getImm(), 36);
167+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, false, true));
168+
BC->MIB->updateBTIVariant(*II, true, true);
169+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, true));
164170

165171
MCInst BTIc;
166172
BC->MIB->createBTI(BTIc, true, false);
167173
II = BB->addInstruction(BTIc);
168174
ASSERT_EQ(II->getOpcode(), AArch64::HINT);
169175
ASSERT_EQ(II->getOperand(0).getImm(), 34);
176+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, false));
177+
BC->MIB->updateBTIVariant(*II, false, true);
178+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, false, true));
170179

180+
#ifndef NDEBUG
171181
MCInst BTIinvalid;
172182
ASSERT_DEATH(BC->MIB->createBTI(BTIinvalid, false, false),
173183
"No target kinds!");
184+
#endif
185+
186+
MCInst Paciasp = MCInstBuilder(AArch64::PACIASP);
187+
II = BB->addInstruction(Paciasp);
188+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, false));
189+
ASSERT_FALSE(BC->MIB->isBTILandingPad(*II, true, true));
190+
ASSERT_FALSE(BC->MIB->isBTILandingPad(*II, false, true));
191+
ASSERT_TRUE(BC->MIB->isImplicitBTIC(*II));
192+
193+
MCInst Pacibsp = MCInstBuilder(AArch64::PACIBSP);
194+
II = BB->addInstruction(Pacibsp);
195+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, false));
196+
ASSERT_FALSE(BC->MIB->isBTILandingPad(*II, true, true));
197+
ASSERT_FALSE(BC->MIB->isBTILandingPad(*II, false, true));
198+
ASSERT_TRUE(BC->MIB->isImplicitBTIC(*II));
174199
}
175200

176201
TEST_P(MCPlusBuilderTester, AArch64_CmpJNE) {

clang-tools-extra/clangd/CompileCommands.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ std::optional<std::string> detectSysroot() {
132132

133133
std::string detectStandardResourceDir() {
134134
static int StaticForMainAddr; // Just an address in this process.
135-
return CompilerInvocation::GetResourcesPath("clangd",
136-
(void *)&StaticForMainAddr);
135+
return GetResourcesPath("clangd", (void *)&StaticForMainAddr);
137136
}
138137

139138
// The path passed to argv[0] is important:

clang-tools-extra/clangd/Compiler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "Compiler.h"
1010
#include "support/Logger.h"
1111
#include "clang/Basic/TargetInfo.h"
12+
#include "clang/Driver/CreateInvocationFromArgs.h"
1213
#include "clang/Frontend/CompilerInvocation.h"
1314
#include "clang/Lex/PreprocessorOptions.h"
1415
#include "clang/Serialization/PCHContainerOperations.h"

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ set(CMAKE_CXX_VISIBILITY_PRESET default CACHE STRING "")
5858

5959
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
6060
if (APPLE)
61-
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "")
61+
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "")
6262
elseif(WIN32)
6363
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
6464
endif()
@@ -83,7 +83,7 @@ if(APPLE)
8383
set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
8484
set(LIBCXX_HARDENING_MODE "none" CACHE STRING "")
8585
set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
86-
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" CACHE STRING "")
86+
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" CACHE STRING "")
8787
endif()
8888

8989
if(WIN32 OR LLVM_WINSYSROOT)

clang/cmake/caches/Fuchsia.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
9797
set(LLVM_ENABLE_BACKTRACES ON CACHE BOOL "")
9898
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
9999
if(APPLE)
100-
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "")
100+
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "")
101101
elseif(WIN32)
102102
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
103103
endif()
@@ -140,7 +140,7 @@ else()
140140
set(SANITIZER_TEST_CXX "libc++" CACHE STRING "")
141141
set(SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "")
142142
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
143-
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" CACHE STRING "")
143+
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" CACHE STRING "")
144144
endif()
145145

146146
if(BOOTSTRAP_CMAKE_SYSTEM_NAME)

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4765,9 +4765,21 @@ the configuration (without a prefix: ``Auto``).
47654765
Decimal: 3
47664766
Hex: -1
47674767

4768-
You can also specify a minimum number of digits (``BinaryMinDigits``,
4769-
``DecimalMinDigits``, and ``HexMinDigits``) the integer literal must
4770-
have in order for the separators to be inserted.
4768+
You can also specify a minimum number of digits
4769+
(``BinaryMinDigitsInsert``, ``DecimalMinDigitsInsert``, and
4770+
``HexMinDigitsInsert``) the integer literal must have in order for the
4771+
separators to be inserted, and a maximum number of digits
4772+
(``BinaryMaxDigitsRemove``, ``DecimalMaxDigitsRemove``, and
4773+
``HexMaxDigitsRemove``) until the separators are removed. This divides the
4774+
literals in 3 regions, always without separator (up until including
4775+
``xxxMaxDigitsRemove``), maybe with, or without separators (up until
4776+
excluding ``xxxMinDigitsInsert``), and finally always with separators.
4777+
4778+
.. note::
4779+
4780+
``BinaryMinDigits``, ``DecimalMinDigits``, and ``HexMinDigits`` are
4781+
deprecated and renamed to ``BinaryMinDigitsInsert``,
4782+
``DecimalMinDigitsInsert``, and ``HexMinDigitsInsert``, respectively.
47714783

47724784
* ``int8_t Binary`` Format separators in binary literals.
47734785

@@ -4778,15 +4790,28 @@ the configuration (without a prefix: ``Auto``).
47784790
/* 3: */ b = 0b100'111'101'101;
47794791
/* 4: */ b = 0b1001'1110'1101;
47804792
4781-
* ``int8_t BinaryMinDigits`` Format separators in binary literals with a minimum number of digits.
4793+
* ``int8_t BinaryMinDigitsInsert`` Format separators in binary literals with a minimum number of digits.
47824794

47834795
.. code-block:: text
47844796
47854797
// Binary: 3
4786-
// BinaryMinDigits: 7
4798+
// BinaryMinDigitsInsert: 7
47874799
b1 = 0b101101;
47884800
b2 = 0b1'101'101;
47894801
4802+
* ``int8_t BinaryMaxDigitsRemove`` Remove separators in binary literals with a maximum number of digits.
4803+
4804+
.. code-block:: text
4805+
4806+
// Binary: 3
4807+
// BinaryMinDigitsInsert: 7
4808+
// BinaryMaxDigitsRemove: 4
4809+
b0 = 0b1011; // Always removed.
4810+
b1 = 0b101101; // Not added.
4811+
b2 = 0b1'01'101; // Not removed, not corrected.
4812+
b3 = 0b1'101'101; // Always added.
4813+
b4 = 0b10'1101; // Corrected to 0b101'101.
4814+
47904815
* ``int8_t Decimal`` Format separators in decimal literals.
47914816

47924817
.. code-block:: text
@@ -4795,15 +4820,28 @@ the configuration (without a prefix: ``Auto``).
47954820
/* 0: */ d = 184467'440737'0'95505'92ull;
47964821
/* 3: */ d = 18'446'744'073'709'550'592ull;
47974822
4798-
* ``int8_t DecimalMinDigits`` Format separators in decimal literals with a minimum number of digits.
4823+
* ``int8_t DecimalMinDigitsInsert`` Format separators in decimal literals with a minimum number of digits.
47994824

48004825
.. code-block:: text
48014826
48024827
// Decimal: 3
4803-
// DecimalMinDigits: 5
4828+
// DecimalMinDigitsInsert: 5
48044829
d1 = 2023;
48054830
d2 = 10'000;
48064831
4832+
* ``int8_t DecimalMaxDigitsRemove`` Remove separators in decimal literals with a maximum number of digits.
4833+
4834+
.. code-block:: text
4835+
4836+
// Decimal: 3
4837+
// DecimalMinDigitsInsert: 7
4838+
// DecimalMaxDigitsRemove: 4
4839+
d0 = 2023; // Always removed.
4840+
d1 = 123456; // Not added.
4841+
d2 = 1'23'456; // Not removed, not corrected.
4842+
d3 = 5'000'000; // Always added.
4843+
d4 = 1'23'45; // Corrected to 12'345.
4844+
48074845
* ``int8_t Hex`` Format separators in hexadecimal literals.
48084846

48094847
.. code-block:: text
@@ -4812,16 +4850,30 @@ the configuration (without a prefix: ``Auto``).
48124850
/* 0: */ h = 0xDEAD'BEEF'DE'AD'BEE'Fuz;
48134851
/* 2: */ h = 0xDE'AD'BE'EF'DE'AD'BE'EFuz;
48144852
4815-
* ``int8_t HexMinDigits`` Format separators in hexadecimal literals with a minimum number of
4853+
* ``int8_t HexMinDigitsInsert`` Format separators in hexadecimal literals with a minimum number of
48164854
digits.
48174855

48184856
.. code-block:: text
48194857
48204858
// Hex: 2
4821-
// HexMinDigits: 6
4859+
// HexMinDigitsInsert: 6
48224860
h1 = 0xABCDE;
48234861
h2 = 0xAB'CD'EF;
48244862
4863+
* ``int8_t HexMaxDigitsRemove`` Remove separators in hexadecimal literals with a maximum number of
4864+
digits.
4865+
4866+
.. code-block:: text
4867+
4868+
// Hex: 2
4869+
// HexMinDigitsInsert: 6
4870+
// HexMaxDigitsRemove: 4
4871+
h0 = 0xAFFE; // Always removed.
4872+
h1 = 0xABCDE; // Not added.
4873+
h2 = 0xABC'DE; // Not removed, not corrected.
4874+
h3 = 0xAB'CD'EF; // Always added.
4875+
h4 = 0xABCD'E; // Corrected to 0xA'BC'DE.
4876+
48254877
48264878
.. _JavaImportGroups:
48274879

0 commit comments

Comments
 (0)