Skip to content

Commit 7654491

Browse files
committed
merge main into amd-staging
2 parents 8c7c451 + 7caa0c9 commit 7654491

File tree

261 files changed

+40318
-2445
lines changed

Some content is hidden

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

261 files changed

+40318
-2445
lines changed

clang-tools-extra/clang-doc/JSONGenerator.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static auto SerializeReferenceLambda = [](const auto &Ref, Object &Object) {
4545

4646
static json::Object
4747
serializeLocation(const Location &Loc,
48-
const std::optional<StringRef> &RepositoryUrl) {
48+
const std::optional<StringRef> RepositoryUrl) {
4949
Object LocationObj = Object();
5050
LocationObj["LineNumber"] = Loc.StartLineNumber;
5151
LocationObj["Filename"] = Loc.Filename;
@@ -169,7 +169,7 @@ static json::Value serializeComment(const CommentInfo &I) {
169169

170170
static void
171171
serializeCommonAttributes(const Info &I, json::Object &Obj,
172-
const std::optional<StringRef> &RepositoryUrl) {
172+
const std::optional<StringRef> RepositoryUrl) {
173173
Obj["Name"] = I.Name;
174174
Obj["USR"] = toHex(toStringRef(I.USR));
175175

@@ -211,9 +211,9 @@ static void serializeReference(const Reference &Ref, Object &ReferenceObj) {
211211
// differently. Only enums, records, and typedefs are handled here.
212212
static void
213213
serializeCommonChildren(const ScopeChildren &Children, json::Object &Obj,
214-
const std::optional<StringRef> &RepositoryUrl) {
215-
static auto SerializeInfo = [&RepositoryUrl](const auto &Info,
216-
Object &Object) {
214+
const std::optional<StringRef> RepositoryUrl) {
215+
static auto SerializeInfo = [RepositoryUrl](const auto &Info,
216+
Object &Object) {
217217
serializeInfo(Info, Object, RepositoryUrl);
218218
};
219219

@@ -304,7 +304,7 @@ static void serializeInfo(const FieldTypeInfo &I, Object &Obj) {
304304
}
305305

306306
static void serializeInfo(const FunctionInfo &F, json::Object &Obj,
307-
const std::optional<StringRef> &RepositoryURL) {
307+
const std::optional<StringRef> RepositoryURL) {
308308
serializeCommonAttributes(F, Obj, RepositoryURL);
309309
Obj["IsStatic"] = F.IsStatic;
310310

@@ -459,7 +459,7 @@ static void serializeInfo(const RecordInfo &I, json::Object &Obj,
459459
}
460460

461461
static void serializeInfo(const VarInfo &I, json::Object &Obj,
462-
const std::optional<StringRef> &RepositoryUrl) {
462+
const std::optional<StringRef> RepositoryUrl) {
463463
serializeCommonAttributes(I, Obj, RepositoryUrl);
464464
Obj["IsStatic"] = I.IsStatic;
465465
auto TypeObj = Object();
@@ -468,15 +468,15 @@ static void serializeInfo(const VarInfo &I, json::Object &Obj,
468468
}
469469

470470
static void serializeInfo(const NamespaceInfo &I, json::Object &Obj,
471-
const std::optional<StringRef> &RepositoryUrl) {
471+
const std::optional<StringRef> RepositoryUrl) {
472472
serializeCommonAttributes(I, Obj, RepositoryUrl);
473473

474474
if (!I.Children.Namespaces.empty())
475475
serializeArray(I.Children.Namespaces, Obj, "Namespaces",
476476
SerializeReferenceLambda);
477477

478-
static auto SerializeInfo = [&RepositoryUrl](const auto &Info,
479-
Object &Object) {
478+
static auto SerializeInfo = [RepositoryUrl](const auto &Info,
479+
Object &Object) {
480480
serializeInfo(Info, Object, RepositoryUrl);
481481
};
482482

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,12 @@ Improvements to Clang's diagnostics
726726
pointer, provided it can be proven that the pointer only points to
727727
``[[noreturn]]`` functions.
728728

729+
- Added a separate diagnostic group ``-Wfunction-effect-redeclarations``, for the more pedantic
730+
diagnostics for function effects (``[[clang::nonblocking]]`` and ``[[clang::nonallocating]]``).
731+
Moved the warning for a missing (though implied) attribute on a redeclaration into this group.
732+
Added a new warning in this group for the case where the attribute is missing/implicit on
733+
an override of a virtual method.
734+
729735
Improvements to Clang's time-trace
730736
----------------------------------
731737

clang/include/clang/Basic/BuiltinsSPIRVVK.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ include "clang/Basic/BuiltinsSPIRVBase.td"
1111

1212
def reflect : SPIRVBuiltin<"void(...)", [NoThrow, Const]>;
1313
def faceforward : SPIRVBuiltin<"void(...)", [NoThrow, Const, CustomTypeChecking]>;
14+
def refract : SPIRVBuiltin<"void(...)", [NoThrow, Const, CustomTypeChecking]>;

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,7 @@ def ThreadSafetyBeta : DiagGroup<"thread-safety-beta">;
12911291
// Warnings and notes related to the function effects system which underlies
12921292
// the nonblocking and nonallocating attributes.
12931293
def FunctionEffects : DiagGroup<"function-effects">;
1294+
def FunctionEffectRedeclarations : DiagGroup<"function-effect-redeclarations">;
12941295
def PerfConstraintImpliesNoexcept : DiagGroup<"perf-constraint-implies-noexcept">;
12951296

12961297
// Uniqueness Analysis warnings

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11526,17 +11526,28 @@ def note_in_evaluating_default_argument : Note<
1152611526
def warn_invalid_add_func_effects : Warning<
1152711527
"attribute '%0' should not be added via type conversion">,
1152811528
InGroup<FunctionEffects>, DefaultIgnore;
11529-
def warn_mismatched_func_effect_override : Warning<
11530-
"attribute '%0' on overriding function does not match base declaration">,
11531-
InGroup<FunctionEffects>, DefaultIgnore;
11532-
def warn_mismatched_func_effect_redeclaration : Warning<
11533-
"attribute '%0' on function does not match previous declaration">,
11534-
InGroup<FunctionEffects>, DefaultIgnore;
11529+
def warn_conflicting_func_effect_override
11530+
: Warning<"attribute '%0' on overriding function conflicts with base "
11531+
"declaration">,
11532+
InGroup<FunctionEffects>,
11533+
DefaultIgnore;
1153511534
def warn_conflicting_func_effects : Warning<
1153611535
"effects conflict when merging declarations; kept '%0', discarded '%1'">,
1153711536
InGroup<FunctionEffects>, DefaultIgnore;
1153811537
def err_func_with_effects_no_prototype : Error<
1153911538
"'%0' function must have a prototype">;
11539+
// These are more pedantic: in redeclarations and virtual method overrides,
11540+
// the effect attribute(s) should be restated.
11541+
def warn_mismatched_func_effect_override
11542+
: Warning<"overriding function is missing '%0' attribute from base "
11543+
"declaration">,
11544+
InGroup<FunctionEffectRedeclarations>,
11545+
DefaultIgnore;
11546+
def warn_mismatched_func_effect_redeclaration
11547+
: Warning<
11548+
"redeclaration is missing '%0' attribute from previous declaration">,
11549+
InGroup<FunctionEffectRedeclarations>,
11550+
DefaultIgnore;
1154011551

1154111552
} // end of sema category
1154211553

@@ -12357,7 +12368,7 @@ def err_export_using_internal : Error<
1235712368
"using declaration referring to %1 with %select{internal|module|unknown}0 "
1235812369
"linkage cannot be exported">;
1235912370
def err_export_not_in_module_interface : Error<
12360-
"export declaration can only be used within a module purview">;
12371+
"export declaration can only be used within a module interface">;
1236112372
def err_export_inline_not_defined : Error<
1236212373
"inline function not defined%select{| before the private module fragment}0">;
1236312374
def err_export_partition_impl : Error<
@@ -13478,6 +13489,12 @@ def err_acc_invalid_default_type
1347813489
def err_acc_device_type_multiple_archs
1347913490
: Error<"OpenACC 'device_type' clause on a 'set' construct only permits "
1348013491
"one architecture">;
13492+
def warn_acc_var_referenced_lacks_op
13493+
: Warning<"variable of type %0 referenced in OpenACC '%1' clause does not "
13494+
"have a %enum_select<AccVarReferencedReason>{%DefCtor{default "
13495+
"constructor}|%Dtor{destructor}}2; reference has no effect">,
13496+
InGroup<DiagGroup<"openacc-var-lacks-operation">>,
13497+
DefaultError;
1348113498

1348213499
// AMDGCN builtins diagnostics
1348313500
def err_amdgcn_load_lds_size_invalid_value : Error<"invalid size value">;

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,22 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
129129
cir::BoolAttr getTrueAttr() { return getCIRBoolAttr(true); }
130130
cir::BoolAttr getFalseAttr() { return getCIRBoolAttr(false); }
131131

132+
mlir::Value createComplexCreate(mlir::Location loc, mlir::Value real,
133+
mlir::Value imag) {
134+
auto resultComplexTy = cir::ComplexType::get(real.getType());
135+
return create<cir::ComplexCreateOp>(loc, resultComplexTy, real, imag);
136+
}
137+
138+
mlir::Value createComplexReal(mlir::Location loc, mlir::Value operand) {
139+
auto operandTy = mlir::cast<cir::ComplexType>(operand.getType());
140+
return create<cir::ComplexRealOp>(loc, operandTy.getElementType(), operand);
141+
}
142+
143+
mlir::Value createComplexImag(mlir::Location loc, mlir::Value operand) {
144+
auto operandTy = mlir::cast<cir::ComplexType>(operand.getType());
145+
return create<cir::ComplexImagOp>(loc, operandTy.getElementType(), operand);
146+
}
147+
132148
mlir::Value createNot(mlir::Value value) {
133149
return create<cir::UnaryOp>(value.getLoc(), value.getType(),
134150
cir::UnaryOpKind::Not, value);
@@ -169,6 +185,11 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
169185
return create<cir::ContinueOp>(loc);
170186
}
171187

188+
mlir::Value createUnaryOp(mlir::Location loc, cir::UnaryOpKind kind,
189+
mlir::Value operand) {
190+
return create<cir::UnaryOp>(loc, kind, operand);
191+
}
192+
172193
mlir::TypedAttr getConstPtrAttr(mlir::Type type, int64_t value) {
173194
return cir::ConstPtrAttr::get(type, getI64IntegerAttr(value));
174195
}

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,6 +2934,45 @@ def CIR_ByteSwapOp : CIR_BitOpBase<"byte_swap",
29342934
}];
29352935
}
29362936

2937+
//===----------------------------------------------------------------------===//
2938+
// RotateOp
2939+
//===----------------------------------------------------------------------===//
2940+
2941+
def CIR_RotateOp : CIR_Op<"rotate", [Pure, SameOperandsAndResultType]> {
2942+
let summary = "Rotate the bits in the operand integer";
2943+
let description = [{
2944+
The `cir.rotate` rotates the bits in `input` by the given amount `amount`.
2945+
The rotate direction is specified by the `left` and `right` keyword.
2946+
2947+
`input` must be an unsigned integer and its width must be either 8, 16, 32,
2948+
or 64. The types of `input`, `amount`, and the result must all match.
2949+
2950+
Example:
2951+
2952+
```mlir
2953+
%r = cir.rotate left %0, %1 : !u32i
2954+
%r = cir.rotate right %0, %1 : !u32i
2955+
```
2956+
}];
2957+
2958+
let results = (outs CIR_IntType:$result);
2959+
let arguments = (ins
2960+
CIR_UIntOfWidths<[8, 16, 32, 64]>:$input,
2961+
CIR_IntType:$amount,
2962+
UnitAttr:$rotateLeft
2963+
);
2964+
2965+
let assemblyFormat = [{
2966+
(`left` $rotateLeft^) : (`right`)?
2967+
$input `,` $amount `:` type($result) attr-dict
2968+
}];
2969+
2970+
let extraClassDeclaration = [{
2971+
bool isRotateLeft() { return getRotateLeft(); }
2972+
bool isRotateRight() { return !getRotateLeft(); }
2973+
}];
2974+
}
2975+
29372976
//===----------------------------------------------------------------------===//
29382977
// Assume Operations
29392978
//===----------------------------------------------------------------------===//

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ struct MissingFeatures {
254254
static bool dtorCleanups() { return false; }
255255
static bool completeDtors() { return false; }
256256
static bool vtableInitialization() { return false; }
257+
static bool msvcBuiltins() { return false; }
257258

258259
// Missing types
259260
static bool dataMemberType() { return false; }

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -348,22 +348,6 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
348348
return CIRBaseBuilderTy::createStore(loc, val, dst.getPointer(), align);
349349
}
350350

351-
mlir::Value createComplexCreate(mlir::Location loc, mlir::Value real,
352-
mlir::Value imag) {
353-
auto resultComplexTy = cir::ComplexType::get(real.getType());
354-
return create<cir::ComplexCreateOp>(loc, resultComplexTy, real, imag);
355-
}
356-
357-
mlir::Value createComplexReal(mlir::Location loc, mlir::Value operand) {
358-
auto operandTy = mlir::cast<cir::ComplexType>(operand.getType());
359-
return create<cir::ComplexRealOp>(loc, operandTy.getElementType(), operand);
360-
}
361-
362-
mlir::Value createComplexImag(mlir::Location loc, mlir::Value operand) {
363-
auto operandTy = mlir::cast<cir::ComplexType>(operand.getType());
364-
return create<cir::ComplexImagOp>(loc, operandTy.getElementType(), operand);
365-
}
366-
367351
/// Create a cir.complex.real_ptr operation that derives a pointer to the real
368352
/// part of the complex value pointed to by the specified pointer value.
369353
mlir::Value createComplexRealPtr(mlir::Location loc, mlir::Value value) {

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ static RValue emitBuiltinBitOp(CIRGenFunction &cgf, const CallExpr *e,
5757
return RValue::get(result);
5858
}
5959

60+
RValue CIRGenFunction::emitRotate(const CallExpr *e, bool isRotateLeft) {
61+
mlir::Value input = emitScalarExpr(e->getArg(0));
62+
mlir::Value amount = emitScalarExpr(e->getArg(1));
63+
64+
// TODO(cir): MSVC flavor bit rotate builtins use different types for input
65+
// and amount, but cir.rotate requires them to have the same type. Cast amount
66+
// to the type of input when necessary.
67+
assert(!cir::MissingFeatures::msvcBuiltins());
68+
69+
auto r = builder.create<cir::RotateOp>(getLoc(e->getSourceRange()), input,
70+
amount, isRotateLeft);
71+
return RValue::get(r);
72+
}
73+
6074
RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
6175
const CallExpr *e,
6276
ReturnValueSlot returnValue) {
@@ -219,6 +233,18 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
219233
mlir::Value arg = emitScalarExpr(e->getArg(0));
220234
return RValue::get(builder.create<cir::BitReverseOp>(loc, arg));
221235
}
236+
237+
case Builtin::BI__builtin_rotateleft8:
238+
case Builtin::BI__builtin_rotateleft16:
239+
case Builtin::BI__builtin_rotateleft32:
240+
case Builtin::BI__builtin_rotateleft64:
241+
return emitRotate(e, /*isRotateLeft=*/true);
242+
243+
case Builtin::BI__builtin_rotateright8:
244+
case Builtin::BI__builtin_rotateright16:
245+
case Builtin::BI__builtin_rotateright32:
246+
case Builtin::BI__builtin_rotateright64:
247+
return emitRotate(e, /*isRotateLeft=*/false);
222248
}
223249

224250
// If this is an alias for a lib function (e.g. __builtin_sin), emit

0 commit comments

Comments
 (0)