Skip to content

Commit a470909

Browse files
authored
merge main into amd-staging (#695)
2 parents 1acee9c + dbb3a6b commit a470909

File tree

144 files changed

+7011
-2749
lines changed

Some content is hidden

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

144 files changed

+7011
-2749
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,12 @@ class MCPlusBuilder {
18881888
llvm_unreachable("not implemented");
18891889
}
18901890

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+
18911897
/// Store \p Target absolute address to \p RegName
18921898
virtual InstructionListType materializeAddress(const MCSymbol *Target,
18931899
MCContext *Ctx,

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,6 +2800,14 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
28002800
Inst.getOpcode() == AArch64::PACIBSP;
28012801
}
28022802

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+
28032811
InstructionListType materializeAddress(const MCSymbol *Target, MCContext *Ctx,
28042812
MCPhysReg RegName,
28052813
int64_t Addend = 0) const override {

bolt/unittests/Core/MCPlusBuilder.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,26 @@ TEST_P(MCPlusBuilderTester, AArch64_BTI) {
156156
ASSERT_EQ(II->getOpcode(), AArch64::HINT);
157157
ASSERT_EQ(II->getOperand(0).getImm(), 38);
158158
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, true));
159+
BC->MIB->updateBTIVariant(*II, true, false);
160+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, false));
159161

160162
MCInst BTIj;
161163
BC->MIB->createBTI(BTIj, false, true);
162164
II = BB->addInstruction(BTIj);
163165
ASSERT_EQ(II->getOpcode(), AArch64::HINT);
164166
ASSERT_EQ(II->getOperand(0).getImm(), 36);
165167
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, false, true));
168+
BC->MIB->updateBTIVariant(*II, true, true);
169+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, true));
166170

167171
MCInst BTIc;
168172
BC->MIB->createBTI(BTIc, true, false);
169173
II = BB->addInstruction(BTIc);
170174
ASSERT_EQ(II->getOpcode(), AArch64::HINT);
171175
ASSERT_EQ(II->getOperand(0).getImm(), 34);
172176
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, false));
177+
BC->MIB->updateBTIVariant(*II, false, true);
178+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, false, true));
173179

174180
#ifndef NDEBUG
175181
MCInst BTIinvalid;

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

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ Improvements to Clang's diagnostics
639639
- Fixed false positives in ``-Waddress-of-packed-member`` diagnostics when
640640
potential misaligned members get processed before they can get discarded.
641641
(#GH144729)
642+
- Fix a false positive warning in ``-Wignored-qualifiers`` when the return type is undeduced. (#GH43054)
642643

643644
- Clang now emits a diagnostic with the correct message in case of assigning to const reference captured in lambda. (#GH105647)
644645

@@ -952,6 +953,9 @@ clang-format
952953
``AlignAfterOpenBracket`` option, and make ``AlignAfterOpenBracket`` a
953954
``bool`` type.
954955
- Add ``AlignPPAndNotPP`` suboption to ``AlignTrailingComments``.
956+
- Rename ``(Binary|Decimal|Hex)MinDigits`` to ``...MinDigitsInsert`` and add
957+
``(Binary|Decimal|Hex)MaxDigitsSeparator`` suboptions to
958+
``IntegerLiteralSeparator``.
955959

956960
libclang
957961
--------

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,8 @@ let Features = "avx512vl",
23712371
def pternlogq256_maskz : X86Builtin<"_Vector<4, long long int>(_Vector<4, long long int>, _Vector<4, long long int>, _Vector<4, long long int>, _Constant int, unsigned char)">;
23722372
}
23732373

2374-
let Features = "avx512f", Attributes = [NoThrow, Const, RequiredVectorWidth<512>] in {
2374+
let Features = "avx512f",
2375+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<512>] in {
23752376
def shuf_f32x4 : X86Builtin<"_Vector<16, float>(_Vector<16, float>, _Vector<16, float>, _Constant int)">;
23762377
def shuf_f64x2 : X86Builtin<"_Vector<8, double>(_Vector<8, double>, _Vector<8, double>, _Constant int)">;
23772378
def shuf_i32x4 : X86Builtin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Constant int)">;
@@ -2391,7 +2392,8 @@ let Features = "avx512f", Attributes = [NoThrow, Const, Constexpr, RequiredVecto
23912392
: X86Builtin<"_Vector<16, float>(_Vector<16, float>, _Vector<16, int>)">;
23922393
}
23932394

2394-
let Features = "avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
2395+
let Features = "avx512vl",
2396+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
23952397
def shuf_f32x4_256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>, _Constant int)">;
23962398
def shuf_f64x2_256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>, _Constant int)">;
23972399
def shuf_i32x4_256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>, _Constant int)">;

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,9 +872,6 @@ def warn_drv_sarif_format_unstable : Warning<
872872
"diagnostic formatting in SARIF mode is currently unstable">,
873873
InGroup<DiagGroup<"sarif-format-unstable">>;
874874

875-
def err_drv_riscv_unsupported_with_linker_relaxation : Error<
876-
"%0 is unsupported with RISC-V linker relaxation (-mrelax)">;
877-
878875
def warn_drv_loongarch_conflicting_implied_val : Warning<
879876
"ignoring '%0' as it conflicts with that implied by '%1' (%2)">,
880877
InGroup<OptionIgnored>;

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4612,6 +4612,16 @@ def CIR_ExpOp : CIR_UnaryFPToFPBuiltinOp<"exp", "ExpOp"> {
46124612
}];
46134613
}
46144614

4615+
def CIR_Exp2Op : CIR_UnaryFPToFPBuiltinOp<"exp2", "Exp2Op"> {
4616+
let summary = "Computes the floating-point base-2 exponential value";
4617+
let description = [{
4618+
`cir.exp2` computes the base-2 exponential of a floating-point operand and
4619+
returns a result of the same type.
4620+
4621+
Floating-point exceptions are ignored, and it does not set `errno`.
4622+
}];
4623+
}
4624+
46154625
def CIR_FAbsOp : CIR_UnaryFPToFPBuiltinOp<"fabs", "FAbsOp"> {
46164626
let summary = "Computes the floating-point absolute value";
46174627
let description = [{

clang/include/clang/Format/Format.h

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3275,9 +3275,20 @@ struct FormatStyle {
32753275
/// Hex: -1
32763276
/// \endcode
32773277
///
3278-
/// You can also specify a minimum number of digits (``BinaryMinDigits``,
3279-
/// ``DecimalMinDigits``, and ``HexMinDigits``) the integer literal must
3280-
/// have in order for the separators to be inserted.
3278+
/// You can also specify a minimum number of digits
3279+
/// (``BinaryMinDigitsInsert``, ``DecimalMinDigitsInsert``, and
3280+
/// ``HexMinDigitsInsert``) the integer literal must have in order for the
3281+
/// separators to be inserted, and a maximum number of digits
3282+
/// (``BinaryMaxDigitsRemove``, ``DecimalMaxDigitsRemove``, and
3283+
/// ``HexMaxDigitsRemove``) until the separators are removed. This divides the
3284+
/// literals in 3 regions, always without separator (up until including
3285+
/// ``xxxMaxDigitsRemove``), maybe with, or without separators (up until
3286+
/// excluding ``xxxMinDigitsInsert``), and finally always with separators.
3287+
/// \note
3288+
/// ``BinaryMinDigits``, ``DecimalMinDigits``, and ``HexMinDigits`` are
3289+
/// deprecated and renamed to ``BinaryMinDigitsInsert``,
3290+
/// ``DecimalMinDigitsInsert``, and ``HexMinDigitsInsert``, respectively.
3291+
/// \endnote
32813292
struct IntegerLiteralSeparatorStyle {
32823293
/// Format separators in binary literals.
32833294
/// \code{.text}
@@ -3290,11 +3301,23 @@ struct FormatStyle {
32903301
/// Format separators in binary literals with a minimum number of digits.
32913302
/// \code{.text}
32923303
/// // Binary: 3
3293-
/// // BinaryMinDigits: 7
3304+
/// // BinaryMinDigitsInsert: 7
32943305
/// b1 = 0b101101;
32953306
/// b2 = 0b1'101'101;
32963307
/// \endcode
3297-
int8_t BinaryMinDigits;
3308+
int8_t BinaryMinDigitsInsert;
3309+
/// Remove separators in binary literals with a maximum number of digits.
3310+
/// \code{.text}
3311+
/// // Binary: 3
3312+
/// // BinaryMinDigitsInsert: 7
3313+
/// // BinaryMaxDigitsRemove: 4
3314+
/// b0 = 0b1011; // Always removed.
3315+
/// b1 = 0b101101; // Not added.
3316+
/// b2 = 0b1'01'101; // Not removed, not corrected.
3317+
/// b3 = 0b1'101'101; // Always added.
3318+
/// b4 = 0b10'1101; // Corrected to 0b101'101.
3319+
/// \endcode
3320+
int8_t BinaryMaxDigitsRemove;
32983321
/// Format separators in decimal literals.
32993322
/// \code{.text}
33003323
/// /* -1: */ d = 18446744073709550592ull;
@@ -3305,11 +3328,23 @@ struct FormatStyle {
33053328
/// Format separators in decimal literals with a minimum number of digits.
33063329
/// \code{.text}
33073330
/// // Decimal: 3
3308-
/// // DecimalMinDigits: 5
3331+
/// // DecimalMinDigitsInsert: 5
33093332
/// d1 = 2023;
33103333
/// d2 = 10'000;
33113334
/// \endcode
3312-
int8_t DecimalMinDigits;
3335+
int8_t DecimalMinDigitsInsert;
3336+
/// Remove separators in decimal literals with a maximum number of digits.
3337+
/// \code{.text}
3338+
/// // Decimal: 3
3339+
/// // DecimalMinDigitsInsert: 7
3340+
/// // DecimalMaxDigitsRemove: 4
3341+
/// d0 = 2023; // Always removed.
3342+
/// d1 = 123456; // Not added.
3343+
/// d2 = 1'23'456; // Not removed, not corrected.
3344+
/// d3 = 5'000'000; // Always added.
3345+
/// d4 = 1'23'45; // Corrected to 12'345.
3346+
/// \endcode
3347+
int8_t DecimalMaxDigitsRemove;
33133348
/// Format separators in hexadecimal literals.
33143349
/// \code{.text}
33153350
/// /* -1: */ h = 0xDEADBEEFDEADBEEFuz;
@@ -3321,15 +3356,36 @@ struct FormatStyle {
33213356
/// digits.
33223357
/// \code{.text}
33233358
/// // Hex: 2
3324-
/// // HexMinDigits: 6
3359+
/// // HexMinDigitsInsert: 6
33253360
/// h1 = 0xABCDE;
33263361
/// h2 = 0xAB'CD'EF;
33273362
/// \endcode
3328-
int8_t HexMinDigits;
3363+
int8_t HexMinDigitsInsert;
3364+
/// Remove separators in hexadecimal literals with a maximum number of
3365+
/// digits.
3366+
/// \code{.text}
3367+
/// // Hex: 2
3368+
/// // HexMinDigitsInsert: 6
3369+
/// // HexMaxDigitsRemove: 4
3370+
/// h0 = 0xAFFE; // Always removed.
3371+
/// h1 = 0xABCDE; // Not added.
3372+
/// h2 = 0xABC'DE; // Not removed, not corrected.
3373+
/// h3 = 0xAB'CD'EF; // Always added.
3374+
/// h4 = 0xABCD'E; // Corrected to 0xA'BC'DE.
3375+
/// \endcode
3376+
int8_t HexMaxDigitsRemove;
33293377
bool operator==(const IntegerLiteralSeparatorStyle &R) const {
3330-
return Binary == R.Binary && BinaryMinDigits == R.BinaryMinDigits &&
3331-
Decimal == R.Decimal && DecimalMinDigits == R.DecimalMinDigits &&
3332-
Hex == R.Hex && HexMinDigits == R.HexMinDigits;
3378+
return Binary == R.Binary &&
3379+
BinaryMinDigitsInsert == R.BinaryMinDigitsInsert &&
3380+
BinaryMaxDigitsRemove == R.BinaryMaxDigitsRemove &&
3381+
Decimal == R.Decimal &&
3382+
DecimalMinDigitsInsert == R.DecimalMinDigitsInsert &&
3383+
DecimalMaxDigitsRemove == R.DecimalMaxDigitsRemove &&
3384+
Hex == R.Hex && HexMinDigitsInsert == R.HexMinDigitsInsert &&
3385+
HexMaxDigitsRemove == R.HexMaxDigitsRemove;
3386+
}
3387+
bool operator!=(const IntegerLiteralSeparatorStyle &R) const {
3388+
return !operator==(R);
33333389
}
33343390
};
33353391

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4847,6 +4847,39 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
48474847
return interp__builtin_elementwise_triop(S, OpPC, Call,
48484848
llvm::APIntOps::fshr);
48494849

4850+
case X86::BI__builtin_ia32_shuf_f32x4_256:
4851+
case X86::BI__builtin_ia32_shuf_i32x4_256:
4852+
case X86::BI__builtin_ia32_shuf_f64x2_256:
4853+
case X86::BI__builtin_ia32_shuf_i64x2_256:
4854+
case X86::BI__builtin_ia32_shuf_f32x4:
4855+
case X86::BI__builtin_ia32_shuf_i32x4:
4856+
case X86::BI__builtin_ia32_shuf_f64x2:
4857+
case X86::BI__builtin_ia32_shuf_i64x2: {
4858+
// Destination and sources A, B all have the same type.
4859+
QualType VecQT = Call->getArg(0)->getType();
4860+
const auto *VecT = VecQT->castAs<VectorType>();
4861+
unsigned NumElems = VecT->getNumElements();
4862+
unsigned ElemBits = S.getASTContext().getTypeSize(VecT->getElementType());
4863+
unsigned LaneBits = 128u;
4864+
unsigned NumLanes = (NumElems * ElemBits) / LaneBits;
4865+
unsigned NumElemsPerLane = LaneBits / ElemBits;
4866+
4867+
return interp__builtin_ia32_shuffle_generic(
4868+
S, OpPC, Call,
4869+
[NumLanes, NumElemsPerLane](unsigned DstIdx, unsigned ShuffleMask) {
4870+
// DstIdx determines source. ShuffleMask selects lane in source.
4871+
unsigned BitsPerElem = NumLanes / 2;
4872+
unsigned IndexMask = (1u << BitsPerElem) - 1;
4873+
unsigned Lane = DstIdx / NumElemsPerLane;
4874+
unsigned SrcIdx = (Lane < NumLanes / 2) ? 0 : 1;
4875+
unsigned BitIdx = BitsPerElem * Lane;
4876+
unsigned SrcLaneIdx = (ShuffleMask >> BitIdx) & IndexMask;
4877+
unsigned ElemInLane = DstIdx % NumElemsPerLane;
4878+
unsigned IdxToPick = SrcLaneIdx * NumElemsPerLane + ElemInLane;
4879+
return std::pair<unsigned, int>{SrcIdx, IdxToPick};
4880+
});
4881+
}
4882+
48504883
case X86::BI__builtin_ia32_insertf32x4_256:
48514884
case X86::BI__builtin_ia32_inserti32x4_256:
48524885
case X86::BI__builtin_ia32_insertf64x2_256:

0 commit comments

Comments
 (0)