Skip to content

Commit 5d7a010

Browse files
authored
merge main into amd-staging (llvm#1786)
2 parents 662bae8 + cf261c6 commit 5d7a010

File tree

293 files changed

+9257
-3632
lines changed

Some content is hidden

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

293 files changed

+9257
-3632
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
/mlir/**/Transforms/SROA.* @moxinilian
129129

130130
# BOLT
131-
/bolt/ @aaupov @maksfb @rafaelauler @ayermolo @dcci @yota9
131+
/bolt/ @aaupov @maksfb @rafaelauler @ayermolo @yota9
132132

133133
# Bazel build system.
134134
/utils/bazel/ @rupprecht @keith @aaronmondal

clang-tools-extra/clangd/unittests/XRefsTests.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,15 @@ TEST(FindReferences, WithinAST) {
23032303
bool $decl[[operator]]"" _u^dl(unsigned long long value);
23042304
bool x = $(x)[[1_udl]];
23052305
)cpp",
2306-
};
2306+
R"cpp(
2307+
struct S {
2308+
public:
2309+
static void $decl(S)[[operator]] delete(void *);
2310+
static void deleteObject(S *S) {
2311+
$(S::deleteObject)[[de^lete]] S;
2312+
}
2313+
};
2314+
)cpp"};
23072315
for (const char *Test : Tests)
23082316
checkFindRefs(Test);
23092317
}

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,10 @@ Improvements to Clang's diagnostics
424424
they're only triggered if the authors are already making the choice to use
425425
``preferred_type`` attribute.
426426

427+
- ``-Winitializer-overrides`` and ``-Wreorder-init-list`` are now grouped under
428+
the ``-Wc99-designator`` diagnostic group, as they also are about the
429+
behavior of the C99 feature as it was introduced into C++20. Fixes #GH47037
430+
427431
Improvements to Clang's time-trace
428432
----------------------------------
429433

clang/include/clang/Basic/AddressSpaces.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ enum class LangAS : unsigned {
6060
hlsl_groupshared,
6161
hlsl_constant,
6262
hlsl_private,
63+
hlsl_device,
6364

6465
// Wasm specific address spaces.
6566
wasm_funcref,

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ def AbstractFinalClass : DiagGroup<"abstract-final-class">;
184184
def FinalDtorNonFinalClass : DiagGroup<"final-dtor-non-final-class">;
185185
def GNUOffsetofExtensions : DiagGroup<"gnu-offsetof-extensions">;
186186

187+
def InitializerOverrides : DiagGroup<"initializer-overrides">;
188+
// For compatibility with GCC; -Woverride-init = -Winitializer-overrides
189+
def : DiagGroup<"override-init", [InitializerOverrides]>;
190+
def ReorderCtor : DiagGroup<"reorder-ctor">;
191+
def ReorderInitList : DiagGroup<"reorder-init-list">;
192+
def Reorder : DiagGroup<"reorder", [ReorderCtor, ReorderInitList]>;
193+
187194
def CXX11CompatDeprecatedWritableStr :
188195
DiagGroup<"c++11-compat-deprecated-writable-strings">;
189196

@@ -250,7 +257,9 @@ def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion,
250257
def CXX20Designator : DiagGroup<"c++20-designator">;
251258
// Allow -Wno-c99-designator to be used to turn off all warnings on valid C99
252259
// designators (including the warning controlled by -Wc++20-designator).
253-
def C99Designator : DiagGroup<"c99-designator", [CXX20Designator]>;
260+
def C99Designator : DiagGroup<"c99-designator", [CXX20Designator,
261+
InitializerOverrides,
262+
ReorderInitList]>;
254263
def GNUDesignator : DiagGroup<"gnu-designator">;
255264
def DtorName : DiagGroup<"dtor-name">;
256265

@@ -595,9 +604,6 @@ def NullabilityCompleteness : DiagGroup<"nullability-completeness",
595604
def NullArithmetic : DiagGroup<"null-arithmetic">;
596605
def NullCharacter : DiagGroup<"null-character">;
597606
def NullDereference : DiagGroup<"null-dereference">;
598-
def InitializerOverrides : DiagGroup<"initializer-overrides">;
599-
// For compatibility with GCC; -Woverride-init = -Winitializer-overrides
600-
def : DiagGroup<"override-init", [InitializerOverrides]>;
601607
def NonNull : DiagGroup<"nonnull">;
602608
def NonPODVarargs : DiagGroup<"non-pod-varargs">;
603609
def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>;
@@ -919,9 +925,6 @@ def UsedButMarkedUnused : DiagGroup<"used-but-marked-unused">;
919925
def UsedSearchPath : DiagGroup<"search-path-usage">;
920926
def UserDefinedLiterals : DiagGroup<"user-defined-literals">;
921927
def UserDefinedWarnings : DiagGroup<"user-defined-warnings">;
922-
def ReorderCtor : DiagGroup<"reorder-ctor">;
923-
def ReorderInitList : DiagGroup<"reorder-init-list">;
924-
def Reorder : DiagGroup<"reorder", [ReorderCtor, ReorderInitList]>;
925928
def UndeclaredSelector : DiagGroup<"undeclared-selector">;
926929
def ImplicitAtomic : DiagGroup<"implicit-atomic-properties">;
927930
def AtomicAlignment : DiagGroup<"atomic-alignment">;

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
6161

6262
mlir::Value getConstAPInt(mlir::Location loc, mlir::Type typ,
6363
const llvm::APInt &val) {
64-
return create<cir::ConstantOp>(loc, typ, getAttr<cir::IntAttr>(typ, val));
64+
return create<cir::ConstantOp>(loc, getAttr<cir::IntAttr>(typ, val));
6565
}
6666

6767
cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr) {
68-
return create<cir::ConstantOp>(loc, attr.getType(), attr);
68+
return create<cir::ConstantOp>(loc, attr);
6969
}
7070

7171
cir::ConstantOp getConstantInt(mlir::Location loc, mlir::Type ty,
@@ -83,21 +83,17 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
8383
return getConstPtrAttr(t, 0);
8484
}
8585

86-
mlir::TypedAttr getZeroAttr(mlir::Type t) {
87-
return cir::ZeroAttr::get(getContext(), t);
88-
}
89-
9086
mlir::TypedAttr getZeroInitAttr(mlir::Type ty) {
9187
if (mlir::isa<cir::IntType>(ty))
9288
return cir::IntAttr::get(ty, 0);
9389
if (cir::isAnyFloatingPointType(ty))
9490
return cir::FPAttr::getZero(ty);
9591
if (auto arrTy = mlir::dyn_cast<cir::ArrayType>(ty))
96-
return getZeroAttr(arrTy);
92+
return cir::ZeroAttr::get(arrTy);
9793
if (auto ptrTy = mlir::dyn_cast<cir::PointerType>(ty))
9894
return getConstNullPtrAttr(ptrTy);
9995
if (auto recordTy = mlir::dyn_cast<cir::RecordType>(ty))
100-
return getZeroAttr(recordTy);
96+
return cir::ZeroAttr::get(recordTy);
10197
if (mlir::isa<cir::BoolType>(ty)) {
10298
return getFalseAttr();
10399
}
@@ -361,6 +357,44 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
361357
return create<cir::CmpOp>(loc, getBoolTy(), kind, lhs, rhs);
362358
}
363359

360+
mlir::Value createShift(mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
361+
bool isShiftLeft) {
362+
return create<cir::ShiftOp>(loc, lhs.getType(), lhs, rhs, isShiftLeft);
363+
}
364+
365+
mlir::Value createShift(mlir::Location loc, mlir::Value lhs,
366+
const llvm::APInt &rhs, bool isShiftLeft) {
367+
return createShift(loc, lhs, getConstAPInt(loc, lhs.getType(), rhs),
368+
isShiftLeft);
369+
}
370+
371+
mlir::Value createShift(mlir::Location loc, mlir::Value lhs, unsigned bits,
372+
bool isShiftLeft) {
373+
auto width = mlir::dyn_cast<cir::IntType>(lhs.getType()).getWidth();
374+
auto shift = llvm::APInt(width, bits);
375+
return createShift(loc, lhs, shift, isShiftLeft);
376+
}
377+
378+
mlir::Value createShiftLeft(mlir::Location loc, mlir::Value lhs,
379+
unsigned bits) {
380+
return createShift(loc, lhs, bits, true);
381+
}
382+
383+
mlir::Value createShiftRight(mlir::Location loc, mlir::Value lhs,
384+
unsigned bits) {
385+
return createShift(loc, lhs, bits, false);
386+
}
387+
388+
mlir::Value createShiftLeft(mlir::Location loc, mlir::Value lhs,
389+
mlir::Value rhs) {
390+
return createShift(loc, lhs, rhs, true);
391+
}
392+
393+
mlir::Value createShiftRight(mlir::Location loc, mlir::Value lhs,
394+
mlir::Value rhs) {
395+
return createShift(loc, lhs, rhs, false);
396+
}
397+
364398
//
365399
// Block handling helpers
366400
// ----------------------

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ def ZeroAttr : CIR_Attr<"Zero", "zero", [TypedAttrInterface]> {
7171
}];
7272

7373
let parameters = (ins AttributeSelfTypeParameter<"">:$type);
74+
75+
let builders = [
76+
AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
77+
return $_get(type.getContext(), type);
78+
}]>
79+
];
80+
7481
let assemblyFormat = [{}];
7582
}
7683

@@ -86,6 +93,13 @@ def UndefAttr : CIR_Attr<"Undef", "undef", [TypedAttrInterface]> {
8693
}];
8794

8895
let parameters = (ins AttributeSelfTypeParameter<"">:$type);
96+
97+
let builders = [
98+
AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
99+
return $_get(type.getContext(), type);
100+
}]>
101+
];
102+
89103
let assemblyFormat = [{}];
90104
}
91105

@@ -100,7 +114,7 @@ def IntAttr : CIR_Attr<"Int", "int", [TypedAttrInterface]> {
100114
value of the specified integer type.
101115
}];
102116
let parameters = (ins AttributeSelfTypeParameter<"">:$type,
103-
"llvm::APInt":$value);
117+
APIntParameter<"">:$value);
104118
let builders = [
105119
AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
106120
"const llvm::APInt &":$value), [{

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

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,9 @@ def ConstantOp : CIR_Op<"const",
288288
```
289289
}];
290290

291-
// The constant operation takes an attribute as the only input.
292291
let arguments = (ins TypedAttrInterface:$value);
293-
294-
// The constant operation returns a single value of CIR_AnyType.
295292
let results = (outs CIR_AnyType:$res);
296293

297-
let builders = [
298-
OpBuilder<(ins "cir::BoolAttr":$value), [{
299-
build($_builder, $_state, value.getType(), value);
300-
}]>
301-
];
302-
303294
let assemblyFormat = "attr-dict $value";
304295

305296
let hasVerifier = 1;
@@ -1182,6 +1173,79 @@ def BinOp : CIR_Op<"binop", [Pure,
11821173
let hasVerifier = 1;
11831174
}
11841175

1176+
//===----------------------------------------------------------------------===//
1177+
// ShiftOp
1178+
//===----------------------------------------------------------------------===//
1179+
1180+
def ShiftOp : CIR_Op<"shift", [Pure]> {
1181+
let summary = "Shift";
1182+
let description = [{
1183+
The `cir.shift` operation performs a bitwise shift, either to the left or to
1184+
the right, based on the first operand. The second operand specifies the
1185+
value to be shifted, and the third operand determines the number of
1186+
positions by which the shift is applied. Both the second and third operands
1187+
are required to be integers.
1188+
1189+
```mlir
1190+
%7 = cir.shift(left, %1 : !u64i, %4 : !s32i) -> !u64i
1191+
```
1192+
}];
1193+
1194+
// TODO(cir): Support vectors. CIR_IntType -> CIR_AnyIntOrVecOfInt. Also
1195+
// update the description above.
1196+
let results = (outs CIR_IntType:$result);
1197+
let arguments = (ins CIR_IntType:$value, CIR_IntType:$amount,
1198+
UnitAttr:$isShiftleft);
1199+
1200+
let assemblyFormat = [{
1201+
`(`
1202+
(`left` $isShiftleft^) : (```right`)?
1203+
`,` $value `:` type($value)
1204+
`,` $amount `:` type($amount)
1205+
`)` `->` type($result) attr-dict
1206+
}];
1207+
1208+
let hasVerifier = 1;
1209+
}
1210+
1211+
//===----------------------------------------------------------------------===//
1212+
// SelectOp
1213+
//===----------------------------------------------------------------------===//
1214+
1215+
def SelectOp : CIR_Op<"select", [Pure,
1216+
AllTypesMatch<["true_value", "false_value", "result"]>]> {
1217+
let summary = "Yield one of two values based on a boolean value";
1218+
let description = [{
1219+
The `cir.select` operation takes three operands. The first operand
1220+
`condition` is a boolean value of type `!cir.bool`. The second and the third
1221+
operand can be of any CIR types, but their types must be the same. If the
1222+
first operand is `true`, the operation yields its second operand. Otherwise,
1223+
the operation yields its third operand.
1224+
1225+
Example:
1226+
1227+
```mlir
1228+
%0 = cir.const #cir.bool<true> : !cir.bool
1229+
%1 = cir.const #cir.int<42> : !s32i
1230+
%2 = cir.const #cir.int<72> : !s32i
1231+
%3 = cir.select if %0 then %1 else %2 : (!cir.bool, !s32i, !s32i) -> !s32i
1232+
```
1233+
}];
1234+
1235+
let arguments = (ins CIR_BoolType:$condition, CIR_AnyType:$true_value,
1236+
CIR_AnyType:$false_value);
1237+
let results = (outs CIR_AnyType:$result);
1238+
1239+
let assemblyFormat = [{
1240+
`if` $condition `then` $true_value `else` $false_value
1241+
`:` `(`
1242+
qualified(type($condition)) `,`
1243+
qualified(type($true_value)) `,`
1244+
qualified(type($false_value))
1245+
`)` `->` qualified(type($result)) attr-dict
1246+
}];
1247+
}
1248+
11851249
//===----------------------------------------------------------------------===//
11861250
// GlobalOp
11871251
//===----------------------------------------------------------------------===//

clang/include/clang/Driver/Distro.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class Distro {
8181
UbuntuNoble,
8282
UbuntuOracular,
8383
UbuntuPlucky,
84+
UbuntuQuesting,
8485
UnknownDistro
8586
};
8687

@@ -132,7 +133,7 @@ class Distro {
132133
}
133134

134135
bool IsUbuntu() const {
135-
return DistroVal >= UbuntuHardy && DistroVal <= UbuntuPlucky;
136+
return DistroVal >= UbuntuHardy && DistroVal <= UbuntuQuesting;
136137
}
137138

138139
bool IsAlpineLinux() const { return DistroVal == AlpineLinux; }

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9243,6 +9243,7 @@ def _SLASH_clr : CLJoined<"clr">;
92439243
def _SLASH_d1 : CLJoined<"d1">;
92449244
def _SLASH_d2 : CLJoined<"d2">;
92459245
def _SLASH_doc : CLJoined<"doc">;
9246+
def _SLASH_dynamicdeopt : CLJoined<"dynamicdeopt">;
92469247
def _SLASH_experimental : CLJoined<"experimental:">;
92479248
def _SLASH_exportHeader : CLFlag<"exportHeader">;
92489249
def _SLASH_external : CLJoined<"external:">;

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,6 +2990,8 @@ bool Compiler<Emitter>::VisitCXXReinterpretCastExpr(
29902990
if (PointeeToT && PointeeFromT) {
29912991
if (isIntegralType(*PointeeFromT) && isIntegralType(*PointeeToT))
29922992
Fatal = false;
2993+
} else {
2994+
Fatal = SubExpr->getType().getTypePtr() != E->getType().getTypePtr();
29932995
}
29942996

29952997
if (!this->emitInvalidCast(CastKind::Reinterpret, Fatal, E))

clang/lib/AST/Type.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ bool Qualifiers::isTargetAddressSpaceSupersetOf(LangAS A, LangAS B,
9494
(A == LangAS::Default &&
9595
(B == LangAS::cuda_constant || B == LangAS::cuda_device ||
9696
B == LangAS::cuda_shared)) ||
97-
// `this` overloading depending on address space is not ready,
98-
// so this is a hack to allow generating addrspacecasts.
99-
// IR legalization will be required when this address space is used.
97+
// In HLSL, the this pointer for member functions points to the default
98+
// address space. This causes a problem if the structure is in
99+
// a different address space. We want to allow casting from these
100+
// address spaces to default to work around this problem.
100101
(A == LangAS::Default && B == LangAS::hlsl_private) ||
102+
(A == LangAS::Default && B == LangAS::hlsl_device) ||
101103
// Conversions from target specific address spaces may be legal
102104
// depending on the target information.
103105
Ctx.getTargetInfo().isAddressSpaceSupersetOf(A, B);

clang/lib/AST/TypePrinter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,8 @@ std::string Qualifiers::getAddrSpaceAsString(LangAS AS) {
26172617
return "hlsl_constant";
26182618
case LangAS::hlsl_private:
26192619
return "hlsl_private";
2620+
case LangAS::hlsl_device:
2621+
return "hlsl_device";
26202622
case LangAS::wasm_funcref:
26212623
return "__funcref";
26222624
default:

clang/lib/Basic/Targets/AArch64.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static const unsigned ARM64AddrSpaceMap[] = {
4646
0, // hlsl_groupshared
4747
0, // hlsl_constant
4848
0, // hlsl_private
49+
0, // hlsl_device
4950
// Wasm address space values for this target are dummy values,
5051
// as it is only enabled for Wasm targets.
5152
20, // wasm_funcref

clang/lib/Basic/Targets/AMDGPU.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
6363
// FIXME(pr/122103): hlsl_private -> PRIVATE is wrong, but at least this
6464
// will break loudly.
6565
llvm::AMDGPUAS::PRIVATE_ADDRESS, // hlsl_private
66+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // hlsl_device
6667
};
6768

6869
const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
@@ -89,6 +90,7 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
8990
llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_groupshared
9091
llvm::AMDGPUAS::CONSTANT_ADDRESS, // hlsl_constant
9192
llvm::AMDGPUAS::PRIVATE_ADDRESS, // hlsl_private
93+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // hlsl_device
9294
};
9395
} // namespace targets
9496
} // namespace clang

clang/lib/Basic/Targets/DirectX.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static const unsigned DirectXAddrSpaceMap[] = {
4444
3, // hlsl_groupshared
4545
2, // hlsl_constant
4646
0, // hlsl_private
47+
0, // hlsl_device
4748
// Wasm address space values for this target are dummy values,
4849
// as it is only enabled for Wasm targets.
4950
20, // wasm_funcref

0 commit comments

Comments
 (0)