Skip to content

Commit 954e714

Browse files
committed
merge main into amd-staging
2 parents 85ce546 + 39bb267 commit 954e714

File tree

342 files changed

+9061
-13916
lines changed

Some content is hidden

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

342 files changed

+9061
-13916
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ Miscellaneous Clang Crashes Fixed
866866
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
867867

868868
- Fixed crash when ``-print-stats`` is enabled in compiling IR files. (#GH131608)
869-
- Fix code completion crash involving PCH serialzied templates. (#GH139019)
869+
- Fix code completion crash involving PCH serialized templates. (#GH139019)
870870

871871
OpenACC Specific Changes
872872
------------------------

clang/include/clang/AST/ExprCXX.h

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ class CXXDefaultArgExpr final
12901290
CXXDefaultArgExprBits.Loc = Loc;
12911291
CXXDefaultArgExprBits.HasRewrittenInit = RewrittenExpr != nullptr;
12921292
if (RewrittenExpr)
1293-
*getTrailingObjects<Expr *>() = RewrittenExpr;
1293+
*getTrailingObjects() = RewrittenExpr;
12941294
setDependence(computeDependence(this));
12951295
}
12961296

@@ -1323,7 +1323,7 @@ class CXXDefaultArgExpr final
13231323
}
13241324

13251325
Expr *getRewrittenExpr() {
1326-
return hasRewrittenInit() ? *getTrailingObjects<Expr *>() : nullptr;
1326+
return hasRewrittenInit() ? *getTrailingObjects() : nullptr;
13271327
}
13281328

13291329
const Expr *getRewrittenExpr() const {
@@ -1421,14 +1421,14 @@ class CXXDefaultInitExpr final
14211421
/// any.
14221422
const Expr *getRewrittenExpr() const {
14231423
assert(hasRewrittenInit() && "expected a rewritten init expression");
1424-
return *getTrailingObjects<Expr *>();
1424+
return *getTrailingObjects();
14251425
}
14261426

14271427
/// Retrieve the initializing expression with evaluated immediate calls, if
14281428
/// any.
14291429
Expr *getRewrittenExpr() {
14301430
assert(hasRewrittenInit() && "expected a rewritten init expression");
1431-
return *getTrailingObjects<Expr *>();
1431+
return *getTrailingObjects();
14321432
}
14331433

14341434
const DeclContext *getUsedContext() const { return UsedContext; }
@@ -1982,8 +1982,8 @@ class LambdaExpr final : public Expr,
19821982
/// Construct an empty lambda expression.
19831983
LambdaExpr(EmptyShell Empty, unsigned NumCaptures);
19841984

1985-
Stmt **getStoredStmts() { return getTrailingObjects<Stmt *>(); }
1986-
Stmt *const *getStoredStmts() const { return getTrailingObjects<Stmt *>(); }
1985+
Stmt **getStoredStmts() { return getTrailingObjects(); }
1986+
Stmt *const *getStoredStmts() const { return getTrailingObjects(); }
19871987

19881988
void initBodyIfNeeded() const;
19891989

@@ -3621,7 +3621,7 @@ class ExprWithCleanups final
36213621
ArrayRef<CleanupObject> objects);
36223622

36233623
ArrayRef<CleanupObject> getObjects() const {
3624-
return getTrailingObjects<CleanupObject>(getNumObjects());
3624+
return getTrailingObjects(getNumObjects());
36253625
}
36263626

36273627
unsigned getNumObjects() const { return ExprWithCleanupsBits.NumObjects; }
@@ -3742,14 +3742,14 @@ class CXXUnresolvedConstructExpr final
37423742
using arg_iterator = Expr **;
37433743
using arg_range = llvm::iterator_range<arg_iterator>;
37443744

3745-
arg_iterator arg_begin() { return getTrailingObjects<Expr *>(); }
3745+
arg_iterator arg_begin() { return getTrailingObjects(); }
37463746
arg_iterator arg_end() { return arg_begin() + getNumArgs(); }
37473747
arg_range arguments() { return arg_range(arg_begin(), arg_end()); }
37483748

37493749
using const_arg_iterator = const Expr* const *;
37503750
using const_arg_range = llvm::iterator_range<const_arg_iterator>;
37513751

3752-
const_arg_iterator arg_begin() const { return getTrailingObjects<Expr *>(); }
3752+
const_arg_iterator arg_begin() const { return getTrailingObjects(); }
37533753
const_arg_iterator arg_end() const { return arg_begin() + getNumArgs(); }
37543754
const_arg_range arguments() const {
37553755
return const_arg_range(arg_begin(), arg_end());
@@ -3860,10 +3860,6 @@ class CXXDependentScopeMemberExpr final
38603860
return getNumTemplateArgs();
38613861
}
38623862

3863-
unsigned numTrailingObjects(OverloadToken<NamedDecl *>) const {
3864-
return hasFirstQualifierFoundInScope();
3865-
}
3866-
38673863
CXXDependentScopeMemberExpr(const ASTContext &Ctx, Expr *Base,
38683864
QualType BaseType, bool IsArrow,
38693865
SourceLocation OperatorLoc,
@@ -4419,7 +4415,7 @@ class SizeOfPackExpr final
44194415
Length(Length ? *Length : PartialArgs.size()), Pack(Pack) {
44204416
assert((!Length || PartialArgs.empty()) &&
44214417
"have partial args for non-dependent sizeof... expression");
4422-
auto *Args = getTrailingObjects<TemplateArgument>();
4418+
auto *Args = getTrailingObjects();
44234419
llvm::uninitialized_copy(PartialArgs, Args);
44244420
setDependence(Length ? ExprDependence::None
44254421
: ExprDependence::ValueInstantiation);
@@ -4472,8 +4468,7 @@ class SizeOfPackExpr final
44724468
/// Get
44734469
ArrayRef<TemplateArgument> getPartialArguments() const {
44744470
assert(isPartiallySubstituted());
4475-
const auto *Args = getTrailingObjects<TemplateArgument>();
4476-
return llvm::ArrayRef(Args, Args + Length);
4471+
return getTrailingObjects(Length);
44774472
}
44784473

44794474
SourceLocation getBeginLoc() const LLVM_READONLY { return OperatorLoc; }
@@ -4517,8 +4512,7 @@ class PackIndexingExpr final
45174512
SubExprs{PackIdExpr, IndexExpr} {
45184513
PackIndexingExprBits.TransformedExpressions = SubstitutedExprs.size();
45194514
PackIndexingExprBits.FullySubstituted = FullySubstituted;
4520-
auto *Exprs = getTrailingObjects<Expr *>();
4521-
llvm::uninitialized_copy(SubstitutedExprs, Exprs);
4515+
llvm::uninitialized_copy(SubstitutedExprs, getTrailingObjects());
45224516

45234517
setDependence(computeDependence(this));
45244518
if (!isInstantiationDependent())
@@ -4583,13 +4577,12 @@ class PackIndexingExpr final
45834577
Expr *getSelectedExpr() const {
45844578
UnsignedOrNone Index = getSelectedIndex();
45854579
assert(Index && "extracting the indexed expression of a dependant pack");
4586-
return getTrailingObjects<Expr *>()[*Index];
4580+
return getTrailingObjects()[*Index];
45874581
}
45884582

45894583
/// Return the trailing expressions, regardless of the expansion.
45904584
ArrayRef<Expr *> getExpressions() const {
4591-
return {getTrailingObjects<Expr *>(),
4592-
PackIndexingExprBits.TransformedExpressions};
4585+
return getTrailingObjects(PackIndexingExprBits.TransformedExpressions);
45934586
}
45944587

45954588
static bool classof(const Stmt *T) {
@@ -4817,7 +4810,7 @@ class FunctionParmPackExpr final
48174810
/// Iterators over the parameters which the parameter pack expanded
48184811
/// into.
48194812
using iterator = ValueDecl *const *;
4820-
iterator begin() const { return getTrailingObjects<ValueDecl *>(); }
4813+
iterator begin() const { return getTrailingObjects(); }
48214814
iterator end() const { return begin() + NumParameters; }
48224815

48234816
/// Get the number of parameters in this parameter pack.
@@ -5099,7 +5092,7 @@ class CXXParenListInitExpr final
50995092
: Expr(CXXParenListInitExprClass, T, getValueKindForType(T), OK_Ordinary),
51005093
NumExprs(Args.size()), NumUserSpecifiedExprs(NumUserSpecifiedExprs),
51015094
InitLoc(InitLoc), LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
5102-
std::copy(Args.begin(), Args.end(), getTrailingObjects<Expr *>());
5095+
llvm::copy(Args, getTrailingObjects());
51035096
assert(NumExprs >= NumUserSpecifiedExprs &&
51045097
"number of user specified inits is greater than the number of "
51055098
"passed inits");
@@ -5124,19 +5117,17 @@ class CXXParenListInitExpr final
51245117
void updateDependence() { setDependence(computeDependence(this)); }
51255118

51265119
MutableArrayRef<Expr *> getInitExprs() {
5127-
return getTrailingObjects<Expr *>(NumExprs);
5120+
return getTrailingObjects(NumExprs);
51285121
}
51295122

5130-
ArrayRef<Expr *> getInitExprs() const {
5131-
return getTrailingObjects<Expr *>(NumExprs);
5132-
}
5123+
ArrayRef<Expr *> getInitExprs() const { return getTrailingObjects(NumExprs); }
51335124

51345125
ArrayRef<Expr *> getUserSpecifiedInitExprs() {
5135-
return getTrailingObjects<Expr *>(NumUserSpecifiedExprs);
5126+
return getTrailingObjects(NumUserSpecifiedExprs);
51365127
}
51375128

51385129
ArrayRef<Expr *> getUserSpecifiedInitExprs() const {
5139-
return getTrailingObjects<Expr *>(NumUserSpecifiedExprs);
5130+
return getTrailingObjects(NumUserSpecifiedExprs);
51405131
}
51415132

51425133
SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
@@ -5172,13 +5163,12 @@ class CXXParenListInitExpr final
51725163
}
51735164

51745165
child_range children() {
5175-
Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
5166+
Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects());
51765167
return child_range(Begin, Begin + NumExprs);
51775168
}
51785169

51795170
const_child_range children() const {
5180-
Stmt *const *Begin =
5181-
reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
5171+
Stmt *const *Begin = reinterpret_cast<Stmt *const *>(getTrailingObjects());
51825172
return const_child_range(Begin, Begin + NumExprs);
51835173
}
51845174

clang/include/clang/Sema/Redeclaration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ enum class RedeclarationKind {
2828
ForExternalRedeclaration
2929
};
3030

31-
#endif // LLVM_CLANG_SEMA_REDECLARATION_H
31+
#endif // LLVM_CLANG_SEMA_REDECLARATION_H

clang/include/clang/Sema/SemaPseudoObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ class SemaPseudoObject : public SemaBase {
3737

3838
} // namespace clang
3939

40-
#endif // LLVM_CLANG_SEMA_SEMAPSEUDOOBJECT_H
40+
#endif // LLVM_CLANG_SEMA_SEMAPSEUDOOBJECT_H

clang/lib/AST/ExprCXX.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &Ctx,
10671067
CXXDefaultInitExprBits.HasRewrittenInit = RewrittenInitExpr != nullptr;
10681068

10691069
if (CXXDefaultInitExprBits.HasRewrittenInit)
1070-
*getTrailingObjects<Expr *>() = RewrittenInitExpr;
1070+
*getTrailingObjects() = RewrittenInitExpr;
10711071

10721072
assert(Field->hasInClassInitializer());
10731073

@@ -1437,8 +1437,7 @@ ExprWithCleanups::ExprWithCleanups(Expr *subexpr,
14371437
: FullExpr(ExprWithCleanupsClass, subexpr) {
14381438
ExprWithCleanupsBits.CleanupsHaveSideEffects = CleanupsHaveSideEffects;
14391439
ExprWithCleanupsBits.NumObjects = objects.size();
1440-
for (unsigned i = 0, e = objects.size(); i != e; ++i)
1441-
getTrailingObjects<CleanupObject>()[i] = objects[i];
1440+
llvm::copy(objects, getTrailingObjects());
14421441
}
14431442

14441443
ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, Expr *subexpr,
@@ -1474,7 +1473,7 @@ CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(
14741473
TypeAndInitForm(TSI, IsListInit), LParenLoc(LParenLoc),
14751474
RParenLoc(RParenLoc) {
14761475
CXXUnresolvedConstructExprBits.NumArgs = Args.size();
1477-
auto **StoredArgs = getTrailingObjects<Expr *>();
1476+
auto **StoredArgs = getTrailingObjects();
14781477
for (unsigned I = 0; I != Args.size(); ++I)
14791478
StoredArgs[I] = Args[I];
14801479
setDependence(computeDependence(this));
@@ -1800,8 +1799,7 @@ FunctionParmPackExpr::FunctionParmPackExpr(QualType T, ValueDecl *ParamPack,
18001799
: Expr(FunctionParmPackExprClass, T, VK_LValue, OK_Ordinary),
18011800
ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) {
18021801
if (Params)
1803-
std::uninitialized_copy(Params, Params + NumParams,
1804-
getTrailingObjects<ValueDecl *>());
1802+
std::uninitialized_copy(Params, Params + NumParams, getTrailingObjects());
18051803
setDependence(ExprDependence::TypeValueInstantiation |
18061804
ExprDependence::UnexpandedPack);
18071805
}

clang/lib/AST/ExprConstant.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15245,21 +15245,7 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
1524515245
return Info.Ctx.getTypeSize(DestType) == Info.Ctx.getTypeSize(SrcType);
1524615246
}
1524715247

15248-
if (Info.Ctx.getLangOpts().CPlusPlus && Info.InConstantContext &&
15249-
Info.EvalMode == EvalInfo::EM_ConstantExpression &&
15250-
DestType->isEnumeralType()) {
15251-
15252-
bool ConstexprVar = true;
15253-
15254-
// We know if we are here that we are in a context that we might require
15255-
// a constant expression or a context that requires a constant
15256-
// value. But if we are initializing a value we don't know if it is a
15257-
// constexpr variable or not. We can check the EvaluatingDecl to determine
15258-
// if it constexpr or not. If not then we don't want to emit a diagnostic.
15259-
if (const auto *VD = dyn_cast_or_null<VarDecl>(
15260-
Info.EvaluatingDecl.dyn_cast<const ValueDecl *>()))
15261-
ConstexprVar = VD->isConstexpr();
15262-
15248+
if (Info.Ctx.getLangOpts().CPlusPlus && DestType->isEnumeralType()) {
1526315249
const EnumType *ET = dyn_cast<EnumType>(DestType.getCanonicalType());
1526415250
const EnumDecl *ED = ET->getDecl();
1526515251
// Check that the value is within the range of the enumeration values.
@@ -15279,13 +15265,13 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
1527915265
ED->getValueRange(Max, Min);
1528015266
--Max;
1528115267

15282-
if (ED->getNumNegativeBits() && ConstexprVar &&
15268+
if (ED->getNumNegativeBits() &&
1528315269
(Max.slt(Result.getInt().getSExtValue()) ||
1528415270
Min.sgt(Result.getInt().getSExtValue())))
1528515271
Info.CCEDiag(E, diag::note_constexpr_unscoped_enum_out_of_range)
1528615272
<< llvm::toString(Result.getInt(), 10) << Min.getSExtValue()
1528715273
<< Max.getSExtValue() << ED;
15288-
else if (!ED->getNumNegativeBits() && ConstexprVar &&
15274+
else if (!ED->getNumNegativeBits() &&
1528915275
Max.ult(Result.getInt().getZExtValue()))
1529015276
Info.CCEDiag(E, diag::note_constexpr_unscoped_enum_out_of_range)
1529115277
<< llvm::toString(Result.getInt(), 10) << Min.getZExtValue()

clang/lib/Analysis/FlowSensitive/Formula.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ void Formula::print(llvm::raw_ostream &OS, const AtomNames *Names) const {
9090
}
9191
}
9292

93-
} // namespace clang::dataflow
93+
} // namespace clang::dataflow

clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,21 @@ class OpenACCClauseCIREmitter final
319319
dataOperands.push_back(afterOp.getOperation());
320320
}
321321

322+
template <typename BeforeOpTy>
323+
void addDataOperand(const Expr *varOperand, mlir::acc::DataClause dataClause,
324+
bool structured, bool implicit) {
325+
DataOperandInfo opInfo = getDataOperandInfo(dirKind, varOperand);
326+
auto beforeOp =
327+
builder.create<BeforeOpTy>(opInfo.beginLoc, opInfo.varValue, structured,
328+
implicit, opInfo.name, opInfo.bounds);
329+
operation.getDataClauseOperandsMutable().append(beforeOp.getResult());
330+
331+
// Set the 'rest' of the info for the operation.
332+
beforeOp.setDataClause(dataClause);
333+
// Make sure we record these, so 'async' values can be updated later.
334+
dataOperands.push_back(beforeOp.getOperation());
335+
}
336+
322337
// Helper function that covers for the fact that we don't have this function
323338
// on all operation types.
324339
mlir::ArrayAttr getAsyncOnlyAttr() {
@@ -550,7 +565,8 @@ class OpenACCClauseCIREmitter final
550565
if constexpr (isOneOfTypes<OpTy, mlir::acc::ParallelOp, mlir::acc::SerialOp,
551566
mlir::acc::KernelsOp, mlir::acc::InitOp,
552567
mlir::acc::ShutdownOp, mlir::acc::SetOp,
553-
mlir::acc::DataOp, mlir::acc::WaitOp>) {
568+
mlir::acc::DataOp, mlir::acc::WaitOp,
569+
mlir::acc::HostDataOp>) {
554570
operation.getIfCondMutable().append(
555571
createCondition(clause.getConditionExpr()));
556572
} else if constexpr (isCombinedType<OpTy>) {
@@ -566,6 +582,17 @@ class OpenACCClauseCIREmitter final
566582
}
567583
}
568584

585+
void VisitIfPresentClause(const OpenACCIfPresentClause &clause) {
586+
if constexpr (isOneOfTypes<OpTy, mlir::acc::HostDataOp>) {
587+
operation.setIfPresent(true);
588+
} else if constexpr (isOneOfTypes<OpTy, mlir::acc::UpdateOp>) {
589+
// Last unimplemented one here, so just put it in this way instead.
590+
return clauseNotImplemented(clause);
591+
} else {
592+
llvm_unreachable("unknown construct kind in VisitIfPresentClause");
593+
}
594+
}
595+
569596
void VisitDeviceNumClause(const OpenACCDeviceNumClause &clause) {
570597
if constexpr (isOneOfTypes<OpTy, mlir::acc::InitOp, mlir::acc::ShutdownOp,
571598
mlir::acc::SetOp>) {
@@ -791,6 +818,33 @@ class OpenACCClauseCIREmitter final
791818
return clauseNotImplemented(clause);
792819
}
793820
}
821+
822+
void VisitUseDeviceClause(const OpenACCUseDeviceClause &clause) {
823+
if constexpr (isOneOfTypes<OpTy, mlir::acc::HostDataOp>) {
824+
for (auto var : clause.getVarList())
825+
addDataOperand<mlir::acc::UseDeviceOp>(
826+
var, mlir::acc::DataClause::acc_use_device,
827+
/*structured=*/true, /*implicit=*/false);
828+
} else {
829+
llvm_unreachable("Unknown construct kind in VisitUseDeviceClause");
830+
}
831+
}
832+
833+
void VisitDevicePtrClause(const OpenACCDevicePtrClause &clause) {
834+
if constexpr (isOneOfTypes<OpTy, mlir::acc::ParallelOp, mlir::acc::SerialOp,
835+
mlir::acc::KernelsOp>) {
836+
for (auto var : clause.getVarList())
837+
addDataOperand<mlir::acc::DevicePtrOp>(
838+
var, mlir::acc::DataClause::acc_deviceptr, /*structured=*/true,
839+
/*implicit=*/false);
840+
} else if constexpr (isCombinedType<OpTy>) {
841+
applyToComputeOp(clause);
842+
} else {
843+
// TODO: When we've implemented this for everything, switch this to an
844+
// unreachable. data, declare remain.
845+
return clauseNotImplemented(clause);
846+
}
847+
}
794848
};
795849

796850
template <typename OpTy>
@@ -826,6 +880,7 @@ EXPL_SPEC(mlir::acc::InitOp)
826880
EXPL_SPEC(mlir::acc::ShutdownOp)
827881
EXPL_SPEC(mlir::acc::SetOp)
828882
EXPL_SPEC(mlir::acc::WaitOp)
883+
EXPL_SPEC(mlir::acc::HostDataOp)
829884
#undef EXPL_SPEC
830885

831886
template <typename ComputeOp, typename LoopOp>

0 commit comments

Comments
 (0)