Skip to content

Commit 5cf45ce

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merge upstream LLVM into amd-gfx12
2 parents 34bbedb + b22b103 commit 5cf45ce

File tree

49 files changed

+3025
-986
lines changed

Some content is hidden

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

49 files changed

+3025
-986
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ related warnings within the method body.
475475
- Clang now disallows the use of attributes applied before an
476476
``extern template`` declaration (#GH79893).
477477

478+
- Clang will print the "reason" string argument passed on to
479+
``[[clang::warn_unused_result("reason")]]`` as part of the warning diagnostic.
480+
478481
Improvements to Clang's diagnostics
479482
-----------------------------------
480483

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

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,7 +2705,7 @@ class CIR_BitOpBase<string mnemonic, TypeConstraint operandTy>
27052705
let results = (outs operandTy:$result);
27062706

27072707
let assemblyFormat = [{
2708-
`(` $input `:` type($input) `)` `:` type($result) attr-dict
2708+
$input `:` type($result) attr-dict
27092709
}];
27102710
}
27112711

@@ -2714,20 +2714,20 @@ class CIR_BitZeroCountOpBase<string mnemonic, TypeConstraint operandTy>
27142714
let arguments = (ins operandTy:$input, UnitAttr:$poison_zero);
27152715

27162716
let assemblyFormat = [{
2717-
`(` $input `:` type($input) `)` (`poison_zero` $poison_zero^)?
2717+
$input (`poison_zero` $poison_zero^)?
27182718
`:` type($result) attr-dict
27192719
}];
27202720
}
27212721

2722-
def BitClrsbOp : CIR_BitOpBase<"bit.clrsb", CIR_SIntOfWidths<[32, 64]>> {
2722+
def BitClrsbOp : CIR_BitOpBase<"clrsb", CIR_SIntOfWidths<[32, 64]>> {
27232723
let summary = "Get the number of leading redundant sign bits in the input";
27242724
let description = [{
27252725
Compute the number of leading redundant sign bits in the input integer.
27262726

27272727
The input integer must be a signed integer. The most significant bit of the
2728-
input integer is the sign bit. The `cir.bit.clrsb` operation returns the
2729-
number of consecutive bits following the sign bit that are identical to the
2730-
sign bit.
2728+
input integer is the sign bit. The `cir.clrsb` operation returns the number
2729+
of consecutive bits following the sign bit that are identical to the sign
2730+
bit.
27312731

27322732
The bit width of the input integer must be either 32 or 64.
27332733

@@ -2738,24 +2738,23 @@ def BitClrsbOp : CIR_BitOpBase<"bit.clrsb", CIR_SIntOfWidths<[32, 64]>> {
27382738
%0 = cir.const #cir.int<3735928559> : !s32i
27392739
// %1 will be 1 because there is 1 bit following the most significant bit
27402740
// that is identical to it.
2741-
%1 = cir.bit.clrsb(%0 : !s32i) : !s32i
2741+
%1 = cir.clrsb %0 : !s32i
27422742

27432743
// %2 = 1, 0b0000_0000_0000_0000_0000_0000_0000_0001
27442744
%2 = cir.const #cir.int<1> : !s32i
27452745
// %3 will be 30 because there are 30 consecutive bits following the sign
27462746
// bit that are identical to the sign bit.
2747-
%3 = cir.bit.clrsb(%2 : !s32i) : !s32i
2747+
%3 = cir.clrsb %2 : !s32i
27482748
```
27492749
}];
27502750
}
27512751

2752-
def BitClzOp : CIR_BitZeroCountOpBase<"bit.clz",
2753-
CIR_UIntOfWidths<[16, 32, 64]>> {
2752+
def BitClzOp : CIR_BitZeroCountOpBase<"clz", CIR_UIntOfWidths<[16, 32, 64]>> {
27542753
let summary = "Get the number of leading 0-bits in the input";
27552754
let description = [{
27562755
Compute the number of leading 0-bits in the input.
27572756

2758-
The input integer must be an unsigned integer. The `cir.bit.clz` operation
2757+
The input integer must be an unsigned integer. The `cir.clz` operation
27592758
returns the number of consecutive 0-bits at the most significant bit
27602759
position in the input.
27612760

@@ -2768,18 +2767,17 @@ def BitClzOp : CIR_BitZeroCountOpBase<"bit.clz",
27682767
// %0 = 0b0000_0000_0000_0000_0000_0000_0000_1000
27692768
%0 = cir.const #cir.int<8> : !u32i
27702769
// %1 will be 28
2771-
%1 = cir.bit.clz(%0 : !u32i) poison_zero : !u32i
2770+
%1 = cir.clz %0 poison_zero : !u32i
27722771
```
27732772
}];
27742773
}
27752774

2776-
def BitCtzOp : CIR_BitZeroCountOpBase<"bit.ctz",
2777-
CIR_UIntOfWidths<[16, 32, 64]>> {
2775+
def BitCtzOp : CIR_BitZeroCountOpBase<"ctz", CIR_UIntOfWidths<[16, 32, 64]>> {
27782776
let summary = "Get the number of trailing 0-bits in the input";
27792777
let description = [{
27802778
Compute the number of trailing 0-bits in the input.
27812779

2782-
The input integer must be an unsigned integer. The `cir.bit.ctz` operation
2780+
The input integer must be an unsigned integer. The `cir.ctz` operation
27832781
counts the number of consecutive 0-bits starting from the least significant
27842782
bit.
27852783

@@ -2792,12 +2790,12 @@ def BitCtzOp : CIR_BitZeroCountOpBase<"bit.ctz",
27922790
// %0 = 0b1000
27932791
%0 = cir.const #cir.int<8> : !u32i
27942792
// %1 will be 3
2795-
%1 = cir.bit.ctz(%0 : !u32i) poison_zero : !u32i
2793+
%1 = cir.ctz %0 poison_zero : !u32i
27962794
```
27972795
}];
27982796
}
27992797

2800-
def BitParityOp : CIR_BitOpBase<"bit.parity", CIR_UIntOfWidths<[32, 64]>> {
2798+
def BitParityOp : CIR_BitOpBase<"parity", CIR_UIntOfWidths<[32, 64]>> {
28012799
let summary = "Get the parity of input";
28022800
let description = [{
28032801
Compute the parity of the input. The parity of an integer is the number of
@@ -2811,13 +2809,12 @@ def BitParityOp : CIR_BitOpBase<"bit.parity", CIR_UIntOfWidths<[32, 64]>> {
28112809
// %0 = 0x0110_1000
28122810
%0 = cir.const #cir.int<104> : !u32i
28132811
// %1 will be 1 since there are three 1-bits in %0
2814-
%1 = cir.bit.parity(%0 : !u32i) : !u32i
2812+
%1 = cir.parity %0 : !u32i
28152813
```
28162814
}];
28172815
}
28182816

2819-
def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
2820-
CIR_UIntOfWidths<[16, 32, 64]>> {
2817+
def BitPopcountOp : CIR_BitOpBase<"popcount", CIR_UIntOfWidths<[16, 32, 64]>> {
28212818
let summary = "Get the number of 1-bits in input";
28222819
let description = [{
28232820
Compute the number of 1-bits in the input.
@@ -2830,25 +2827,22 @@ def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
28302827
// %0 = 0x0110_1000
28312828
%0 = cir.const #cir.int<104> : !u32i
28322829
// %1 will be 3 since there are 3 1-bits in %0
2833-
%1 = cir.bit.popcnt(%0 : !u32i) : !u32i
2830+
%1 = cir.popcount %0 : !u32i
28342831
```
28352832
}];
28362833
}
28372834

2838-
def BitReverseOp : CIR_BitOpBase<"bit.reverse",
2835+
def BitReverseOp : CIR_BitOpBase<"bitreverse",
28392836
CIR_UIntOfWidths<[8, 16, 32, 64]>> {
28402837
let summary = "Reverse the bit pattern of the operand integer";
28412838
let description = [{
2842-
The `cir.bit.reverse` operation reverses the bits of the operand integer.
2843-
Its only argument must be of unsigned integer types of width 8, 16, 32, or
2844-
64.
2845-
2846-
This operation covers the C/C++ builtin function `__builtin_bitreverse`.
2839+
The `cir.bitreverse` operation reverses the bits of the operand integer. Its
2840+
only argument must be of unsigned integer types of width 8, 16, 32, or 64.
28472841

28482842
Example:
28492843

28502844
```mlir
2851-
%1 = cir.bit.reverse(%0 : !u32i): !u32i
2845+
%1 = cir.bitreverse %0: !u32i
28522846
```
28532847
}];
28542848
}
@@ -2869,7 +2863,7 @@ def ByteSwapOp : CIR_BitOpBase<"byte_swap", CIR_UIntOfWidths<[16, 32, 64]>> {
28692863
%0 = cir.const #cir.int<305419896> : !u32i
28702864

28712865
// %1 should be 0x78563412
2872-
%1 = cir.byte_swap(%0 : !u32i) : !u32i
2866+
%1 = cir.byte_swap %0 : !u32i
28732867
```
28742868
}];
28752869
}

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2902,28 +2902,37 @@ static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL) {
29022902
}
29032903

29042904
StringRef Str;
2905-
if (AL.isStandardAttributeSyntax() && !AL.getScopeName()) {
2906-
// The standard attribute cannot be applied to variable declarations such
2907-
// as a function pointer.
2908-
if (isa<VarDecl>(D))
2909-
S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
2910-
<< AL << AL.isRegularKeywordAttribute()
2911-
<< ExpectedFunctionOrClassOrEnum;
2912-
2913-
// If this is spelled as the standard C++17 attribute, but not in C++17,
2914-
// warn about using it as an extension. If there are attribute arguments,
2915-
// then claim it's a C++20 extension instead. C23 supports this attribute
2916-
// with the message; no extension warning is needed there beyond the one
2917-
// already issued for accepting attributes in older modes.
2918-
const LangOptions &LO = S.getLangOpts();
2919-
if (AL.getNumArgs() == 1) {
2920-
if (LO.CPlusPlus && !LO.CPlusPlus20)
2921-
S.Diag(AL.getLoc(), diag::ext_cxx20_attr) << AL;
2922-
2923-
if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, nullptr))
2905+
if (AL.isStandardAttributeSyntax()) {
2906+
// If this is spelled [[clang::warn_unused_result]] we look for an optional
2907+
// string literal. This is not gated behind any specific version of the
2908+
// standard.
2909+
if (AL.isClangScope()) {
2910+
if (AL.getNumArgs() == 1 &&
2911+
!S.checkStringLiteralArgumentAttr(AL, 0, Str, nullptr))
29242912
return;
2925-
} else if (LO.CPlusPlus && !LO.CPlusPlus17)
2926-
S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL;
2913+
} else if (!AL.getScopeName()) {
2914+
// The standard attribute cannot be applied to variable declarations such
2915+
// as a function pointer.
2916+
if (isa<VarDecl>(D))
2917+
S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
2918+
<< AL << AL.isRegularKeywordAttribute()
2919+
<< ExpectedFunctionOrClassOrEnum;
2920+
2921+
// If this is spelled as the standard C++17 attribute, but not in C++17,
2922+
// warn about using it as an extension. If there are attribute arguments,
2923+
// then claim it's a C++20 extension instead. C23 supports this attribute
2924+
// with the message; no extension warning is needed there beyond the one
2925+
// already issued for accepting attributes in older modes.
2926+
const LangOptions &LO = S.getLangOpts();
2927+
if (AL.getNumArgs() == 1) {
2928+
if (LO.CPlusPlus && !LO.CPlusPlus20)
2929+
S.Diag(AL.getLoc(), diag::ext_cxx20_attr) << AL;
2930+
2931+
if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, nullptr))
2932+
return;
2933+
} else if (LO.CPlusPlus && !LO.CPlusPlus17)
2934+
S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL;
2935+
}
29272936
}
29282937

29292938
if ((!AL.isGNUAttribute() &&

0 commit comments

Comments
 (0)