Skip to content

Commit 541aec4

Browse files
authored
Merge branch 'main' into hgh/libcxx/nodiscard-to-any
2 parents da2b700 + 5b8656c commit 541aec4

File tree

188 files changed

+6971
-2318
lines changed

Some content is hidden

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

188 files changed

+6971
-2318
lines changed

.git-blame-ignore-revs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,12 @@ a3a007ad5fa20abc90ead4e1030b481bf109b4cf
143143
b7e332d3f59f567b1999fbcc660d7837cba8e406
144144
6056f942abe83b05406df8b04e95ec37a3d160b5
145145
906295b8a31c8dac5aa845864c0bca9f02f86184
146+
147+
# [clang-tidy][NFC] Remove trailing whitespaces in documentation
148+
8f2b167de4a1268160c06512d08863a9e8f43290
149+
150+
# [clang-tidy][NFC] Enforce 80 characters limit in docs
151+
5edf70c41c5d69f3751b4199f642f4585599dade
152+
c73870dbe89a8219130e21a0b3f13df76d299352
153+
74c40293c309dbd142bf1f0ebfbfde6be8d30655
154+
a7ba8dcad76476478100c228a31d9c48391b1e03

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ Improvements to Clang's diagnostics
441441
- Clang no longer emits ``-Wmissing-noreturn`` for virtual methods where
442442
the function body consists of a `throw` expression (#GH167247).
443443

444+
- A new warning ``-Wenum-compare-typo`` has been added to detect potential erroneous
445+
comparison operators when mixed with bitwise operators in enum value initializers.
446+
This can be locally disabled by explicitly casting the initializer value.
447+
444448
Improvements to Clang's time-trace
445449
----------------------------------
446450

clang/include/clang/Basic/BuiltinsSPIRVVK.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ include "clang/Basic/BuiltinsSPIRVBase.td"
1212
def reflect : SPIRVBuiltin<"void(...)", [NoThrow, Const]>;
1313
def faceforward : SPIRVBuiltin<"void(...)", [NoThrow, Const, CustomTypeChecking]>;
1414
def refract : SPIRVBuiltin<"void(...)", [NoThrow, Const, CustomTypeChecking]>;
15+
def fwidth : SPIRVBuiltin<"void(...)", [NoThrow, Const, CustomTypeChecking]>;

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 49 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -91,42 +91,6 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<128>] in {
9191
def cmppd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Constant char)">;
9292
def cmpsd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Constant char)">;
9393
}
94-
95-
let Features = "sse3",
96-
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
97-
foreach Op = ["addsub"] in {
98-
def Op#ps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>)">;
99-
def Op#pd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>)">;
100-
}
101-
}
102-
103-
let Features = "sse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
104-
foreach Op = ["hadd", "hsub"] in {
105-
def Op#ps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>)">;
106-
def Op#pd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>)">;
107-
}
108-
}
109-
110-
let Features = "ssse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
111-
def psignb128
112-
: X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>)">;
113-
def psignw128
114-
: X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
115-
def psignd128
116-
: X86Builtin<"_Vector<4, int>(_Vector<4, int>, _Vector<4, int>)">;
117-
def pmulhrsw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
118-
def pmaddubsw128 : X86Builtin<"_Vector<8, short>(_Vector<16, char>, _Vector<16, char>)">;
119-
def pshufb128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>)">;
120-
}
121-
}
122-
123-
// AVX
124-
let Attributes = [Const, NoThrow, RequiredVectorWidth<256>],
125-
Features = "avx" in {
126-
foreach Op = ["max", "min"] in {
127-
def Op#pd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>)">;
128-
def Op#ps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>)">;
129-
}
13094
}
13195

13296
let Features = "mmx", Header = "mmintrin.h", Attributes = [NoThrow, Const] in {
@@ -312,11 +276,22 @@ let Features = "sse3", Attributes = [NoThrow, RequiredVectorWidth<128>] in {
312276
def lddqu : X86Builtin<"_Vector<16, char>(char const *)">;
313277
}
314278

315-
let Features = "ssse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
316-
def palignr128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>, _Constant int)">;
279+
let Features = "sse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
280+
foreach Op = ["addsub", "hadd", "hsub"] in {
281+
def Op#ps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>)">;
282+
def Op#pd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>)">;
283+
}
317284
}
318285

319286
let Features = "ssse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
287+
def palignr128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>, _Constant int)">;
288+
def pmulhrsw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
289+
def pmaddubsw128 : X86Builtin<"_Vector<8, short>(_Vector<16, char>, _Vector<16, char>)">;
290+
def pshufb128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>)">;
291+
def psignb128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>)">;
292+
def psignw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
293+
def psignd128 : X86Builtin<"_Vector<4, int>(_Vector<4, int>, _Vector<4, int>)">;
294+
320295
foreach Op = ["phadd", "phsub"] in {
321296
def Op#w128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
322297
def Op#sw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
@@ -330,25 +305,13 @@ let Features = "sse4.1", Attributes = [NoThrow, Const, RequiredVectorWidth<128>]
330305
def roundsd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Constant int)">;
331306
def roundpd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Constant int)">;
332307
def dpps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>, _Constant char)">;
333-
def dppd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, "
334-
"_Vector<2,double>, _Constant char)">;
335-
def mpsadbw128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, "
336-
"_Vector<16, char>, _Constant char)">;
337-
}
338-
339-
let Features = "sse4.1",
340-
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
341-
def insertps128 : X86Builtin<"_Vector<4, float>(_Vector<4, float>, "
342-
"_Vector<4, float>, _Constant char)">;
343-
def ptestz128
344-
: X86Builtin<"int(_Vector<2, long long int>, _Vector<2, long long int>)">;
345-
def ptestc128
346-
: X86Builtin<"int(_Vector<2, long long int>, _Vector<2, long long int>)">;
347-
def ptestnzc128
348-
: X86Builtin<"int(_Vector<2, long long int>, _Vector<2, long long int>)">;
308+
def dppd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2,double>, _Constant char)">;
309+
def mpsadbw128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>, _Constant char)">;
349310
}
350311

351312
let Features = "sse4.1", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
313+
def insertps128 : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>, _Constant char)">;
314+
352315
def pblendw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>, _Constant int)">;
353316
def blendpd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Constant int)">;
354317
def blendps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>, _Constant int)">;
@@ -360,6 +323,10 @@ let Features = "sse4.1", Attributes = [NoThrow, Const, Constexpr, RequiredVector
360323
def packusdw128 : X86Builtin<"_Vector<8, short>(_Vector<4, int>, _Vector<4, int>)">;
361324
def phminposuw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>)">;
362325

326+
def ptestz128 : X86Builtin<"int(_Vector<2, long long int>, _Vector<2, long long int>)">;
327+
def ptestc128 : X86Builtin<"int(_Vector<2, long long int>, _Vector<2, long long int>)">;
328+
def ptestnzc128 : X86Builtin<"int(_Vector<2, long long int>, _Vector<2, long long int>)">;
329+
363330
def vec_ext_v16qi : X86Builtin<"char(_Vector<16, char>, _Constant int)">;
364331
def vec_set_v16qi : X86Builtin<"_Vector<16, char>(_Vector<16, char>, char, _Constant int)">;
365332
def vec_set_v4si : X86Builtin<"_Vector<4, int>(_Vector<4, int>, int, _Constant int)">;
@@ -510,6 +477,11 @@ let Features = "avx", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in
510477
def vperm2f128_pd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>, _Constant int)">;
511478
def vperm2f128_ps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>, _Constant int)">;
512479
def vperm2f128_si256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>, _Constant int)">;
480+
481+
foreach Op = ["max", "min"] in {
482+
def Op#pd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>)">;
483+
def Op#ps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>)">;
484+
}
513485
}
514486

515487
let Features = "avx", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
@@ -531,7 +503,7 @@ let Features = "avx", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWid
531503
def vpermilpd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Constant int)">;
532504
def vpermilps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Constant int)">;
533505

534-
foreach Op = ["hadd", "hsub"] in {
506+
foreach Op = ["addsub", "hadd", "hsub"] in {
535507
def Op#pd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>)">;
536508
def Op#ps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>)">;
537509
}
@@ -572,15 +544,6 @@ let Features = "avx",
572544
def movmskps256 : X86Builtin<"int(_Vector<8, float>)">;
573545
}
574546

575-
let Features = "avx",
576-
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
577-
def addsubpd256
578-
: X86Builtin<
579-
"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>)">;
580-
def addsubps256
581-
: X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>)">;
582-
}
583-
584547
let Features = "avx", Attributes = [NoThrow] in {
585548
def vzeroall : X86Builtin<"void()">;
586549
def vzeroupper : X86Builtin<"void()">;
@@ -2506,24 +2469,28 @@ let Features = "avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256
25062469
def rsqrt14ps256_mask : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>, unsigned char)">;
25072470
}
25082471

2509-
let Features = "avx512bw", Attributes = [NoThrow, Const, RequiredVectorWidth<512>] in {
2472+
let Features = "avx512bw",
2473+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<512>] in {
25102474
def cvtb2mask512 : X86Builtin<"unsigned long long int(_Vector<64, char>)">;
25112475
def cvtmask2b512 : X86Builtin<"_Vector<64, char>(unsigned long long int)">;
25122476
def cvtmask2w512 : X86Builtin<"_Vector<32, short>(unsigned int)">;
25132477
}
25142478

2515-
let Features = "avx512dq", Attributes = [NoThrow, Const, RequiredVectorWidth<512>] in {
2479+
let Features = "avx512dq",
2480+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<512>] in {
25162481
def cvtd2mask512 : X86Builtin<"unsigned short(_Vector<16, int>)">;
25172482
def cvtmask2d512 : X86Builtin<"_Vector<16, int>(unsigned short)">;
25182483
def cvtmask2q512 : X86Builtin<"_Vector<8, long long int>(unsigned char)">;
25192484
def cvtq2mask512 : X86Builtin<"unsigned char(_Vector<8, long long int>)">;
25202485
}
25212486

2522-
let Features = "avx512bw,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
2487+
let Features = "avx512bw,avx512vl",
2488+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
25232489
def cvtb2mask128 : X86Builtin<"unsigned short(_Vector<16, char>)">;
25242490
}
25252491

2526-
let Features = "avx512bw,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
2492+
let Features = "avx512bw,avx512vl",
2493+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
25272494
def cvtb2mask256 : X86Builtin<"unsigned int(_Vector<32, char>)">;
25282495
}
25292496

@@ -2543,11 +2510,13 @@ let Features = "avx512bw,avx512vl", Attributes = [NoThrow, Const, RequiredVector
25432510
def cvtmask2w256 : X86Builtin<"_Vector<16, short>(unsigned short)">;
25442511
}
25452512

2546-
let Features = "avx512dq,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
2513+
let Features = "avx512dq,avx512vl",
2514+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
25472515
def cvtd2mask128 : X86Builtin<"unsigned char(_Vector<4, int>)">;
25482516
}
25492517

2550-
let Features = "avx512dq,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
2518+
let Features = "avx512dq,avx512vl",
2519+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
25512520
def cvtd2mask256 : X86Builtin<"unsigned char(_Vector<8, int>)">;
25522521
}
25532522

@@ -2567,11 +2536,13 @@ let Features = "avx512dq,avx512vl", Attributes = [NoThrow, Const, RequiredVector
25672536
def cvtmask2q256 : X86Builtin<"_Vector<4, long long int>(unsigned char)">;
25682537
}
25692538

2570-
let Features = "avx512dq,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
2539+
let Features = "avx512dq,avx512vl",
2540+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
25712541
def cvtq2mask128 : X86Builtin<"unsigned char(_Vector<2, long long int>)">;
25722542
}
25732543

2574-
let Features = "avx512dq,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
2544+
let Features = "avx512dq,avx512vl",
2545+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
25752546
def cvtq2mask256 : X86Builtin<"unsigned char(_Vector<4, long long int>)">;
25762547
}
25772548

@@ -3365,15 +3336,18 @@ let Features = "avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256
33653336
def vcvtps2ph256_mask : X86Builtin<"_Vector<8, short>(_Vector<8, float>, _Constant int, _Vector<8, short>, unsigned char)">;
33663337
}
33673338

3368-
let Features = "avx512bw", Attributes = [NoThrow, Const, RequiredVectorWidth<512>] in {
3339+
let Features = "avx512bw",
3340+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<512>] in {
33693341
def cvtw2mask512 : X86Builtin<"unsigned int(_Vector<32, short>)">;
33703342
}
33713343

3372-
let Features = "avx512bw,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
3344+
let Features = "avx512bw,avx512vl",
3345+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
33733346
def cvtw2mask128 : X86Builtin<"unsigned char(_Vector<8, short>)">;
33743347
}
33753348

3376-
let Features = "avx512bw,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
3349+
let Features = "avx512bw,avx512vl",
3350+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
33773351
def cvtw2mask256 : X86Builtin<"unsigned short(_Vector<16, short>)">;
33783352
}
33793353

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13739,4 +13739,12 @@ def err_amdgcn_load_lds_size_invalid_value : Error<"invalid size value">;
1373913739
def note_amdgcn_load_lds_size_valid_value : Note<"size must be %select{1, 2, or 4|1, 2, 4, 12 or 16}0">;
1374013740

1374113741
def err_amdgcn_coop_atomic_invalid_as : Error<"cooperative atomic requires a global or generic pointer">;
13742+
13743+
def warn_comparison_in_enum_initializer : Warning<
13744+
"comparison operator '%0' is potentially a typo for a shift operator '%1'">,
13745+
InGroup<DiagGroup<"enum-compare-typo">>;
13746+
13747+
def note_enum_compare_typo_suggest : Note<
13748+
"use '%0' to perform a bitwise shift">;
13749+
1374213750
} // end of sema component.

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3362,6 +3362,28 @@ static bool interp__builtin_ia32_vpconflict(InterpState &S, CodePtr OpPC,
33623362
return true;
33633363
}
33643364

3365+
static bool interp__builtin_ia32_cvt_vec2mask(InterpState &S, CodePtr OpPC,
3366+
const CallExpr *Call,
3367+
unsigned ID) {
3368+
assert(Call->getNumArgs() == 1);
3369+
3370+
const Pointer &Vec = S.Stk.pop<Pointer>();
3371+
unsigned RetWidth = S.getASTContext().getIntWidth(Call->getType());
3372+
APInt RetMask(RetWidth, 0);
3373+
3374+
unsigned VectorLen = Vec.getNumElems();
3375+
PrimType ElemT = Vec.getFieldDesc()->getPrimType();
3376+
3377+
for (unsigned ElemNum = 0; ElemNum != VectorLen; ++ElemNum) {
3378+
APSInt A;
3379+
INT_TYPE_SWITCH_NO_BOOL(ElemT, { A = Vec.elem<T>(ElemNum).toAPSInt(); });
3380+
unsigned MSB = A[A.getBitWidth() - 1];
3381+
RetMask.setBitVal(ElemNum, MSB);
3382+
}
3383+
pushInteger(S, RetMask, Call->getType());
3384+
return true;
3385+
}
3386+
33653387
static bool interp__builtin_ia32_shuffle_generic(
33663388
InterpState &S, CodePtr OpPC, const CallExpr *Call,
33673389
llvm::function_ref<std::pair<unsigned, int>(unsigned, unsigned)>
@@ -4779,6 +4801,20 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
47794801
case X86::BI__builtin_ia32_vec_set_v4di:
47804802
return interp__builtin_vec_set(S, OpPC, Call, BuiltinID);
47814803

4804+
case X86::BI__builtin_ia32_cvtb2mask128:
4805+
case X86::BI__builtin_ia32_cvtb2mask256:
4806+
case X86::BI__builtin_ia32_cvtb2mask512:
4807+
case X86::BI__builtin_ia32_cvtw2mask128:
4808+
case X86::BI__builtin_ia32_cvtw2mask256:
4809+
case X86::BI__builtin_ia32_cvtw2mask512:
4810+
case X86::BI__builtin_ia32_cvtd2mask128:
4811+
case X86::BI__builtin_ia32_cvtd2mask256:
4812+
case X86::BI__builtin_ia32_cvtd2mask512:
4813+
case X86::BI__builtin_ia32_cvtq2mask128:
4814+
case X86::BI__builtin_ia32_cvtq2mask256:
4815+
case X86::BI__builtin_ia32_cvtq2mask512:
4816+
return interp__builtin_ia32_cvt_vec2mask(S, OpPC, Call, BuiltinID);
4817+
47824818
case X86::BI__builtin_ia32_cmpb128_mask:
47834819
case X86::BI__builtin_ia32_cmpw128_mask:
47844820
case X86::BI__builtin_ia32_cmpd128_mask:

clang/lib/AST/ExprConstant.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16593,6 +16593,37 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
1659316593
return Success(Vec.getVectorElt(Idx).getInt(), E);
1659416594
}
1659516595

16596+
case clang::X86::BI__builtin_ia32_cvtb2mask128:
16597+
case clang::X86::BI__builtin_ia32_cvtb2mask256:
16598+
case clang::X86::BI__builtin_ia32_cvtb2mask512:
16599+
case clang::X86::BI__builtin_ia32_cvtw2mask128:
16600+
case clang::X86::BI__builtin_ia32_cvtw2mask256:
16601+
case clang::X86::BI__builtin_ia32_cvtw2mask512:
16602+
case clang::X86::BI__builtin_ia32_cvtd2mask128:
16603+
case clang::X86::BI__builtin_ia32_cvtd2mask256:
16604+
case clang::X86::BI__builtin_ia32_cvtd2mask512:
16605+
case clang::X86::BI__builtin_ia32_cvtq2mask128:
16606+
case clang::X86::BI__builtin_ia32_cvtq2mask256:
16607+
case clang::X86::BI__builtin_ia32_cvtq2mask512: {
16608+
assert(E->getNumArgs() == 1);
16609+
APValue Vec;
16610+
if (!EvaluateVector(E->getArg(0), Vec, Info))
16611+
return false;
16612+
16613+
unsigned VectorLen = Vec.getVectorLength();
16614+
unsigned RetWidth = Info.Ctx.getIntWidth(E->getType());
16615+
llvm::APInt Bits(RetWidth, 0);
16616+
16617+
for (unsigned ElemNum = 0; ElemNum != VectorLen; ++ElemNum) {
16618+
const APSInt &A = Vec.getVectorElt(ElemNum).getInt();
16619+
unsigned MSB = A[A.getBitWidth() - 1];
16620+
Bits.setBitVal(ElemNum, MSB);
16621+
}
16622+
16623+
APSInt RetMask(Bits, /*isUnsigned=*/true);
16624+
return Success(APValue(RetMask), E);
16625+
}
16626+
1659616627
case clang::X86::BI__builtin_ia32_cmpb128_mask:
1659716628
case clang::X86::BI__builtin_ia32_cmpw128_mask:
1659816629
case clang::X86::BI__builtin_ia32_cmpd128_mask:

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,9 +1189,20 @@ LValue CIRGenFunction::emitExtVectorElementExpr(const ExtVectorElementExpr *e) {
11891189
base = emitLValue(e->getBase());
11901190
} else {
11911191
// Otherwise, the base is a normal rvalue (as in (V+V).x), emit it as such.
1192-
cgm.errorNYI(e->getSourceRange(),
1193-
"emitExtVectorElementExpr: base is a normal rvalue");
1194-
return {};
1192+
assert(e->getBase()->getType()->isVectorType() &&
1193+
"Result must be a vector");
1194+
mlir::Value vec = emitScalarExpr(e->getBase());
1195+
1196+
// Store the vector to memory (because LValue wants an address).
1197+
QualType baseTy = e->getBase()->getType();
1198+
Address vecMem = createMemTemp(baseTy, vec.getLoc(), "tmp");
1199+
if (!getLangOpts().HLSL && baseTy->isExtVectorBoolType()) {
1200+
cgm.errorNYI(e->getSourceRange(),
1201+
"emitExtVectorElementExpr: ExtVectorBoolType & !HLSL");
1202+
return {};
1203+
}
1204+
builder.createStore(vec.getLoc(), vec, vecMem);
1205+
base = makeAddrLValue(vecMem, baseTy, AlignmentSource::Decl);
11951206
}
11961207

11971208
QualType type =

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6644,6 +6644,7 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType,
66446644

66456645
if (auto *CalleeDecl = dyn_cast_or_null<FunctionDecl>(TargetDecl)) {
66466646
if (CalleeDecl->hasAttr<RestrictAttr>() ||
6647+
CalleeDecl->hasAttr<MallocSpanAttr>() ||
66476648
CalleeDecl->hasAttr<AllocSizeAttr>()) {
66486649
// Function has 'malloc' (aka. 'restrict') or 'alloc_size' attribute.
66496650
if (SanOpts.has(SanitizerKind::AllocToken)) {

0 commit comments

Comments
 (0)