Skip to content

Commit 2d2f549

Browse files
committed
Merge from 'main' to 'sycl-web' (63 commits)
CONFLICT (content): Merge conflict in libclc/clc/lib/ptx-nvidiacl/SOURCES CONFLICT (add/add): Merge conflict in libclc/clc/lib/ptx-nvidiacl/math/clc_log.cl CONFLICT (add/add): Merge conflict in libclc/clc/lib/ptx-nvidiacl/math/clc_sinpi.cl CONFLICT (add/add): Merge conflict in libclc/clc/lib/ptx-nvidiacl/math/clc_sqrt.cl
2 parents 8ecbd20 + 12cec43 commit 2d2f549

File tree

247 files changed

+3222
-2274
lines changed

Some content is hidden

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

247 files changed

+3222
-2274
lines changed

.git-blame-ignore-revs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,3 @@ a3a007ad5fa20abc90ead4e1030b481bf109b4cf
143143
b7e332d3f59f567b1999fbcc660d7837cba8e406
144144
6056f942abe83b05406df8b04e95ec37a3d160b5
145145
906295b8a31c8dac5aa845864c0bca9f02f86184
146-
147-
# [mlir][tensor][linalg] Move Pack/UnPack Ops to Linalg
148-
517800e37e8d3a4ee84214bef65e227612c2a98b

clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,12 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) {
238238
? MemberCallObject
239239
: (Pointee ? Pointee : Result.Nodes.getNodeAs<Expr>("STLObject"));
240240
FixItHint Hint;
241-
std::string ReplacementText = std::string(
242-
Lexer::getSourceText(CharSourceRange::getTokenRange(E->getSourceRange()),
243-
*Result.SourceManager, getLangOpts()));
241+
std::string ReplacementText =
242+
E->isImplicitCXXThis()
243+
? ""
244+
: std::string(Lexer::getSourceText(
245+
CharSourceRange::getTokenRange(E->getSourceRange()),
246+
*Result.SourceManager, getLangOpts()));
244247
const auto *OpCallExpr = dyn_cast<CXXOperatorCallExpr>(E);
245248
if (isBinaryOrTernary(E) || isa<UnaryOperator>(E) ||
246249
(OpCallExpr && (OpCallExpr->getOperator() == OO_Star))) {
@@ -251,6 +254,8 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) {
251254
// This can happen if the object is a smart pointer. Don't add anything
252255
// because a '->' is already there (PR#51776), just call the method.
253256
ReplacementText += "empty()";
257+
} else if (E->isImplicitCXXThis()) {
258+
ReplacementText += "empty()";
254259
} else if (E->getType()->isPointerType())
255260
ReplacementText += "->empty()";
256261
else

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ Changes in existing checks
186186
<clang-tidy/checks/portability/template-virtual-member-function>` check to
187187
avoid false positives on pure virtual member functions.
188188

189+
- Improved :doc:`readability-container-size-empty
190+
<clang-tidy/checks/readability/container-size-empty>` check by correctly
191+
generating fix-it hints when size method is called from implicit ``this``.
192+
189193
- Improved :doc:`readability-identifier-naming
190194
<clang-tidy/checks/readability/identifier-naming>` check by ignoring
191195
declarations in system headers.

clang-tools-extra/test/clang-tidy/checkers/readability/container-size-empty.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,3 +895,16 @@ namespace PR94454 {
895895
int operator""_ci() { return 0; }
896896
auto eq = 0_ci == 0;
897897
}
898+
899+
namespace GH152387 {
900+
901+
class foo : public std::string{
902+
void doit() {
903+
if (!size()) {
904+
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be used to check for emptiness instead of 'size'
905+
// CHECK-FIXES: if (empty()) {
906+
}
907+
}
908+
};
909+
910+
}

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ Bug Fixes to C++ Support
188188
(``[[assume(expr)]]``) creates temporary objects.
189189
- Fix the dynamic_cast to final class optimization to correctly handle
190190
casts that are guaranteed to fail (#GH137518).
191+
- Fix bug rejecting partial specialization of variable templates with auto NTTPs (#GH118190).
191192

192193
Bug Fixes to AST Handling
193194
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -234,6 +235,9 @@ RISC-V Support
234235
- Add support for `__attribute__((interrupt("rnmi")))` to be used with the `Smrnmi` extension.
235236
With this the `Smrnmi` extension is fully supported.
236237

238+
- Add `-march=unset` to clear any previous `-march=` value. This ISA string will
239+
be computed from `-mcpu` or the platform default.
240+
237241
CUDA/HIP Language Changes
238242
^^^^^^^^^^^^^^^^^^^^^^^^^
239243

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,6 +3186,56 @@ def CIR_AssumeOp : CIR_Op<"assume"> {
31863186
}];
31873187
}
31883188

3189+
def CIR_AssumeAlignedOp : CIR_Op<"assume_aligned", [
3190+
Pure, AllTypesMatch<["pointer", "result"]>
3191+
]> {
3192+
let summary = "Tell the optimizer that a pointer is aligned";
3193+
let description = [{
3194+
The `cir.assume_aligned` operation takes two or three arguments. The first
3195+
argument `pointer` gives the pointer value whose alignment is to be assumed,
3196+
and the second argument `align` is an integer attribute that gives the
3197+
assumed alignment.
3198+
3199+
The `offset` argument is optional. If given, it represents misalignment
3200+
offset. When it's present, this operation tells the optimizer that the
3201+
pointer is always misaligned to the alignment by `offset` bytes, a.k.a. the
3202+
pointer yielded by `(char *)pointer - offset` is aligned to the specified
3203+
alignment. Note that the `offset` argument is an SSA value rather than an
3204+
attribute, which means that you could pass a dynamically determined value
3205+
as the mialignment offset.
3206+
3207+
The result of this operation has the same value as the `pointer` argument,
3208+
but it additionally carries any alignment information indicated by this
3209+
operation.
3210+
3211+
This operation corresponds to the `__builtin_assume_aligned` builtin
3212+
function.
3213+
3214+
Example:
3215+
3216+
```mlir
3217+
// Assume that %0 is a CIR pointer value of type !cir.ptr<!s32i>
3218+
%1 = cir.assume_aligned %0 alignment 16 : !cir.ptr<!s32i>
3219+
3220+
// With a misalignment offset of 4 bytes:
3221+
%2 = cir.const #cir.int<4> : !u64i
3222+
%3 = cir.assume_aligned %0 alignment 16 [offset %2 : !u64i] : !cir.ptr<!s32i>
3223+
```
3224+
}];
3225+
3226+
let arguments = (ins CIR_PointerType:$pointer,
3227+
I64Attr:$alignment,
3228+
Optional<CIR_IntType>:$offset);
3229+
let results = (outs CIR_PointerType:$result);
3230+
3231+
let assemblyFormat = [{
3232+
$pointer
3233+
`alignment` $alignment
3234+
(`[` `offset` $offset^ `:` type($offset) `]`)?
3235+
`:` qualified(type($pointer)) attr-dict
3236+
}];
3237+
}
3238+
31893239
def CIR_AssumeSepStorageOp : CIR_Op<"assume_separate_storage", [
31903240
SameTypeOperands
31913241
]> {

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
667667
}
668668

669669
case CK_VectorSplat: {
670-
assert(!classify(CE->getType()));
671-
assert(classify(SubExpr->getType()));
670+
assert(!canClassify(CE->getType()));
671+
assert(canClassify(SubExpr->getType()));
672672
assert(CE->getType()->isVectorType());
673673

674674
if (!Initializing) {
@@ -1932,15 +1932,10 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
19321932
dyn_cast<EmbedExpr>(Init->IgnoreParenImpCasts())) {
19331933
PrimType TargetT = classifyPrim(Init->getType());
19341934

1935-
auto Eval = [&](const Expr *Init, unsigned ElemIndex) {
1936-
PrimType InitT = classifyPrim(Init->getType());
1937-
if (!this->visit(Init))
1935+
auto Eval = [&](const IntegerLiteral *IL, unsigned ElemIndex) {
1936+
if (!this->emitConst(IL->getValue(), Init))
19381937
return false;
1939-
if (InitT != TargetT) {
1940-
if (!this->emitCast(InitT, TargetT, E))
1941-
return false;
1942-
}
1943-
return this->emitInitElem(TargetT, ElemIndex, Init);
1938+
return this->emitInitElem(TargetT, ElemIndex, IL);
19441939
};
19451940
if (!EmbedS->doForEachDataElement(Eval, ElementIndex))
19461941
return false;
@@ -2062,21 +2057,36 @@ bool Compiler<Emitter>::visitArrayElemInit(unsigned ElemIndex, const Expr *Init,
20622057
template <class Emitter>
20632058
bool Compiler<Emitter>::visitCallArgs(ArrayRef<const Expr *> Args,
20642059
const FunctionDecl *FuncDecl,
2065-
bool Activate) {
2060+
bool Activate, bool IsOperatorCall) {
20662061
assert(VarScope->getKind() == ScopeKind::Call);
20672062
llvm::BitVector NonNullArgs;
20682063
if (FuncDecl && FuncDecl->hasAttr<NonNullAttr>())
20692064
NonNullArgs = collectNonNullArgs(FuncDecl, Args);
20702065

2066+
bool ExplicitMemberFn = false;
2067+
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(FuncDecl))
2068+
ExplicitMemberFn = MD->isExplicitObjectMemberFunction();
2069+
20712070
unsigned ArgIndex = 0;
20722071
for (const Expr *Arg : Args) {
2073-
if (OptPrimType T = classify(Arg)) {
2072+
if (canClassify(Arg)) {
20742073
if (!this->visit(Arg))
20752074
return false;
20762075
} else {
20772076

2078-
std::optional<unsigned> LocalIndex = allocateLocal(
2079-
Arg, Arg->getType(), /*ExtendingDecl=*/nullptr, ScopeKind::Call);
2077+
DeclTy Source = Arg;
2078+
if (FuncDecl) {
2079+
// Try to use the parameter declaration instead of the argument
2080+
// expression as a source.
2081+
unsigned DeclIndex = ArgIndex - IsOperatorCall + ExplicitMemberFn;
2082+
if (DeclIndex < FuncDecl->getNumParams())
2083+
Source = FuncDecl->getParamDecl(ArgIndex - IsOperatorCall +
2084+
ExplicitMemberFn);
2085+
}
2086+
2087+
std::optional<unsigned> LocalIndex =
2088+
allocateLocal(std::move(Source), Arg->getType(),
2089+
/*ExtendingDecl=*/nullptr, ScopeKind::Call);
20802090
if (!LocalIndex)
20812091
return false;
20822092

@@ -3155,7 +3165,7 @@ bool Compiler<Emitter>::VisitCXXNoexceptExpr(const CXXNoexceptExpr *E) {
31553165
template <class Emitter>
31563166
bool Compiler<Emitter>::VisitCXXConstructExpr(const CXXConstructExpr *E) {
31573167
QualType T = E->getType();
3158-
assert(!classify(T));
3168+
assert(!canClassify(T));
31593169

31603170
if (T->isRecordType()) {
31613171
const CXXConstructorDecl *Ctor = E->getConstructor();
@@ -4150,7 +4160,7 @@ template <class Emitter> bool Compiler<Emitter>::visit(const Expr *E) {
41504160

41514161
// Create local variable to hold the return value.
41524162
if (!E->isGLValue() && !E->getType()->isAnyComplexType() &&
4153-
!classify(E->getType())) {
4163+
!canClassify(E->getType())) {
41544164
std::optional<unsigned> LocalIndex = allocateLocal(E);
41554165
if (!LocalIndex)
41564166
return false;
@@ -4170,7 +4180,7 @@ template <class Emitter> bool Compiler<Emitter>::visit(const Expr *E) {
41704180

41714181
template <class Emitter>
41724182
bool Compiler<Emitter>::visitInitializer(const Expr *E) {
4173-
assert(!classify(E->getType()));
4183+
assert(!canClassify(E->getType()));
41744184

41754185
OptionScope<Emitter> Scope(this, /*NewDiscardResult=*/false,
41764186
/*NewInitializing=*/true);
@@ -4377,7 +4387,7 @@ bool Compiler<Emitter>::visitZeroArrayInitializer(QualType T, const Expr *E) {
43774387
template <class Emitter>
43784388
bool Compiler<Emitter>::visitAssignment(const Expr *LHS, const Expr *RHS,
43794389
const Expr *E) {
4380-
if (!classify(E->getType()))
4390+
if (!canClassify(E->getType()))
43814391
return false;
43824392

43834393
if (!this->visit(RHS))
@@ -4489,14 +4499,6 @@ template <class Emitter>
44894499
unsigned Compiler<Emitter>::allocateLocalPrimitive(
44904500
DeclTy &&Src, PrimType Ty, bool IsConst, const ValueDecl *ExtendingDecl,
44914501
ScopeKind SC, bool IsConstexprUnknown) {
4492-
// Make sure we don't accidentally register the same decl twice.
4493-
if (const auto *VD =
4494-
dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>())) {
4495-
assert(!P.getGlobal(VD));
4496-
assert(!Locals.contains(VD));
4497-
(void)VD;
4498-
}
4499-
45004502
// FIXME: There are cases where Src.is<Expr*>() is wrong, e.g.
45014503
// (int){12} in C. Consider using Expr::isTemporaryObject() instead
45024504
// or isa<MaterializeTemporaryExpr>().
@@ -4518,19 +4520,11 @@ std::optional<unsigned>
45184520
Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
45194521
const ValueDecl *ExtendingDecl, ScopeKind SC,
45204522
bool IsConstexprUnknown) {
4521-
// Make sure we don't accidentally register the same decl twice.
4522-
if ([[maybe_unused]] const auto *VD =
4523-
dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>())) {
4524-
assert(!P.getGlobal(VD));
4525-
assert(!Locals.contains(VD));
4526-
}
4527-
45284523
const ValueDecl *Key = nullptr;
45294524
const Expr *Init = nullptr;
45304525
bool IsTemporary = false;
45314526
if (auto *VD = dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>())) {
45324527
Key = VD;
4533-
Ty = VD->getType();
45344528

45354529
if (const auto *VarD = dyn_cast<VarDecl>(VD))
45364530
Init = VarD->getInit();
@@ -5167,7 +5161,8 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
51675161
return false;
51685162
}
51695163

5170-
if (!this->visitCallArgs(Args, FuncDecl, IsAssignmentOperatorCall))
5164+
if (!this->visitCallArgs(Args, FuncDecl, IsAssignmentOperatorCall,
5165+
isa<CXXOperatorCallExpr>(E)))
51715166
return false;
51725167

51735168
// Undo the argument reversal we did earlier.
@@ -7140,10 +7135,6 @@ bool Compiler<Emitter>::emitDestruction(const Descriptor *Desc,
71407135
assert(!Desc->isPrimitive());
71417136
assert(!Desc->isPrimitiveArray());
71427137

7143-
// Can happen if the decl is invalid.
7144-
if (Desc->isDummy())
7145-
return true;
7146-
71477138
// Arrays.
71487139
if (Desc->isArray()) {
71497140
const Descriptor *ElemDesc = Desc->ElemDesc;

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
256256

257257
OptPrimType classify(const Expr *E) const { return Ctx.classify(E); }
258258
OptPrimType classify(QualType Ty) const { return Ctx.classify(Ty); }
259+
bool canClassify(const Expr *E) const { return Ctx.canClassify(E); }
260+
bool canClassify(QualType T) const { return Ctx.canClassify(T); }
259261

260262
/// Classifies a known primitive type.
261263
PrimType classifyPrim(QualType Ty) const {
@@ -304,7 +306,7 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
304306
bool visitArrayElemInit(unsigned ElemIndex, const Expr *Init,
305307
OptPrimType InitT);
306308
bool visitCallArgs(ArrayRef<const Expr *> Args, const FunctionDecl *FuncDecl,
307-
bool Activate);
309+
bool Activate, bool IsOperatorCall);
308310

309311
/// Creates a local primitive value.
310312
unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst,

clang/lib/AST/ByteCode/Context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ const Function *Context::getOrCreateFunction(const FunctionDecl *FuncDecl) {
501501
// elsewhere in the code.
502502
QualType Ty = FuncDecl->getReturnType();
503503
bool HasRVO = false;
504-
if (!Ty->isVoidType() && !classify(Ty)) {
504+
if (!Ty->isVoidType() && !canClassify(Ty)) {
505505
HasRVO = true;
506506
ParamTypes.push_back(PT_Ptr);
507507
ParamOffsets.push_back(ParamOffset);

clang/lib/AST/ByteCode/Context.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ class Context final {
9393
return classify(E->getType());
9494
}
9595

96+
bool canClassify(QualType T) {
97+
if (const auto *BT = dyn_cast<BuiltinType>(T)) {
98+
if (BT->isInteger() || BT->isFloatingPoint())
99+
return true;
100+
if (BT->getKind() == BuiltinType::Bool)
101+
return true;
102+
}
103+
104+
if (T->isArrayType() || T->isRecordType() || T->isAnyComplexType() ||
105+
T->isVectorType())
106+
return false;
107+
return classify(T) != std::nullopt;
108+
}
109+
bool canClassify(const Expr *E) {
110+
if (E->isGLValue())
111+
return true;
112+
return canClassify(E->getType());
113+
}
114+
96115
const CXXMethodDecl *
97116
getOverridingFunction(const CXXRecordDecl *DynamicDecl,
98117
const CXXRecordDecl *StaticDecl,

0 commit comments

Comments
 (0)