Skip to content

Commit f0daa1f

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:89a080cb79972abae240c226090af9a3094e2269 into amd-gfx:93971a479db3
Local branch amd-gfx 93971a4 Merged main:9f858c7b79f9edff082050b930fee347887f8e6d into amd-gfx:d168cedb5f80 Remote branch main 89a080c [llvm][NFC] Document cl::opt MisExpectTolerance and fix typo
2 parents 93971a4 + 89a080c commit f0daa1f

Some content is hidden

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

52 files changed

+3514
-1137
lines changed

clang/include/clang/AST/OpenACCClause.h

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include "clang/AST/StmtIterator.h"
1818
#include "clang/Basic/OpenACCKinds.h"
1919

20-
#include <utility>
21-
2220
namespace clang {
2321
/// This is the base type for all OpenACC Clauses.
2422
class OpenACCClause {
@@ -77,63 +75,6 @@ class OpenACCClauseWithParams : public OpenACCClause {
7775
}
7876
};
7977

80-
using DeviceTypeArgument = std::pair<IdentifierInfo *, SourceLocation>;
81-
/// A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or
82-
/// an identifier. The 'asterisk' means 'the rest'.
83-
class OpenACCDeviceTypeClause final
84-
: public OpenACCClauseWithParams,
85-
public llvm::TrailingObjects<OpenACCDeviceTypeClause,
86-
DeviceTypeArgument> {
87-
// Data stored in trailing objects as IdentifierInfo* /SourceLocation pairs. A
88-
// nullptr IdentifierInfo* represents an asterisk.
89-
unsigned NumArchs;
90-
OpenACCDeviceTypeClause(OpenACCClauseKind K, SourceLocation BeginLoc,
91-
SourceLocation LParenLoc,
92-
ArrayRef<DeviceTypeArgument> Archs,
93-
SourceLocation EndLoc)
94-
: OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc),
95-
NumArchs(Archs.size()) {
96-
assert(
97-
(K == OpenACCClauseKind::DeviceType || K == OpenACCClauseKind::DType) &&
98-
"Invalid clause kind for device-type");
99-
100-
assert(!llvm::any_of(Archs, [](const DeviceTypeArgument &Arg) {
101-
return Arg.second.isInvalid();
102-
}) && "Invalid SourceLocation for an argument");
103-
104-
assert(Archs.size() == 1 ||
105-
!llvm::any_of(Archs,
106-
[](const DeviceTypeArgument &Arg) {
107-
return Arg.first == nullptr;
108-
}) &&
109-
"Only a single asterisk version is permitted, and must be the "
110-
"only one");
111-
112-
std::uninitialized_copy(Archs.begin(), Archs.end(),
113-
getTrailingObjects<DeviceTypeArgument>());
114-
}
115-
116-
public:
117-
static bool classof(const OpenACCClause *C) {
118-
return C->getClauseKind() == OpenACCClauseKind::DType ||
119-
C->getClauseKind() == OpenACCClauseKind::DeviceType;
120-
}
121-
bool hasAsterisk() const {
122-
return getArchitectures().size() > 0 &&
123-
getArchitectures()[0].first == nullptr;
124-
}
125-
126-
ArrayRef<DeviceTypeArgument> getArchitectures() const {
127-
return ArrayRef<DeviceTypeArgument>(
128-
getTrailingObjects<DeviceTypeArgument>(), NumArchs);
129-
}
130-
131-
static OpenACCDeviceTypeClause *
132-
Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc,
133-
SourceLocation LParenLoc, ArrayRef<DeviceTypeArgument> Archs,
134-
SourceLocation EndLoc);
135-
};
136-
13778
/// A 'default' clause, has the optional 'none' or 'present' argument.
13879
class OpenACCDefaultClause : public OpenACCClauseWithParams {
13980
friend class ASTReaderStmt;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12344,8 +12344,4 @@ def warn_acc_deprecated_alias_name
1234412344
def err_acc_var_not_pointer_type
1234512345
: Error<"expected pointer in '%0' clause, type is %1">;
1234612346
def note_acc_expected_pointer_var : Note<"expected variable of pointer type">;
12347-
def err_acc_clause_after_device_type
12348-
: Error<"OpenACC clause '%0' may not follow a '%1' clause in a "
12349-
"compute construct">;
12350-
1235112347
} // end of sema component.

clang/include/clang/Basic/OpenACCClauses.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ CLAUSE_ALIAS(PCreate, Create)
3737
CLAUSE_ALIAS(PresentOrCreate, Create)
3838
VISIT_CLAUSE(Default)
3939
VISIT_CLAUSE(DevicePtr)
40-
VISIT_CLAUSE(DeviceType)
41-
CLAUSE_ALIAS(DType, DeviceType)
4240
VISIT_CLAUSE(FirstPrivate)
4341
VISIT_CLAUSE(If)
4442
VISIT_CLAUSE(NoCreate)

clang/include/clang/Parse/Parser.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3720,8 +3720,7 @@ class Parser : public CodeCompletionHandler {
37203720
SourceLocation Loc,
37213721
llvm::SmallVectorImpl<Expr *> &IntExprs);
37223722
/// Parses the 'device-type-list', which is a list of identifiers.
3723-
bool ParseOpenACCDeviceTypeList(
3724-
llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>> &Archs);
3723+
bool ParseOpenACCDeviceTypeList();
37253724
/// Parses the 'async-argument', which is an integral value with two
37263725
/// 'special' values that are likely negative (but come from Macros).
37273726
OpenACCIntExprParseResult ParseOpenACCAsyncArgument(OpenACCDirectiveKind DK,

clang/include/clang/Sema/SemaOpenACC.h

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ class OpenACCClause;
2626

2727
class SemaOpenACC : public SemaBase {
2828
public:
29-
// Redeclaration of the version in OpenACCClause.h.
30-
using DeviceTypeArgument = std::pair<IdentifierInfo *, SourceLocation>;
31-
3229
/// A type to represent all the data for an OpenACC Clause that has been
3330
/// parsed, but not yet created/semantically analyzed. This is effectively a
3431
/// discriminated union on the 'Clause Kind', with all of the individual
@@ -63,12 +60,8 @@ class SemaOpenACC : public SemaBase {
6360
SmallVector<Expr *> QueueIdExprs;
6461
};
6562

66-
struct DeviceTypeDetails {
67-
SmallVector<DeviceTypeArgument> Archs;
68-
};
69-
7063
std::variant<std::monostate, DefaultDetails, ConditionDetails,
71-
IntExprDetails, VarListDetails, WaitDetails, DeviceTypeDetails>
64+
IntExprDetails, VarListDetails, WaitDetails>
7265
Details = std::monostate{};
7366

7467
public:
@@ -216,13 +209,6 @@ class SemaOpenACC : public SemaBase {
216209
return std::get<VarListDetails>(Details).IsZero;
217210
}
218211

219-
ArrayRef<DeviceTypeArgument> getDeviceTypeArchitectures() const {
220-
assert((ClauseKind == OpenACCClauseKind::DeviceType ||
221-
ClauseKind == OpenACCClauseKind::DType) &&
222-
"Only 'device_type'/'dtype' has a device-type-arg list");
223-
return std::get<DeviceTypeDetails>(Details).Archs;
224-
}
225-
226212
void setLParenLoc(SourceLocation EndLoc) { LParenLoc = EndLoc; }
227213
void setEndLoc(SourceLocation EndLoc) { ClauseRange.setEnd(EndLoc); }
228214

@@ -340,13 +326,6 @@ class SemaOpenACC : public SemaBase {
340326
"Parsed clause kind does not have a wait-details");
341327
Details = WaitDetails{DevNum, QueuesLoc, std::move(IntExprs)};
342328
}
343-
344-
void setDeviceTypeDetails(llvm::SmallVector<DeviceTypeArgument> &&Archs) {
345-
assert((ClauseKind == OpenACCClauseKind::DeviceType ||
346-
ClauseKind == OpenACCClauseKind::DType) &&
347-
"Only 'device_type'/'dtype' has a device-type-arg list");
348-
Details = DeviceTypeDetails{std::move(Archs)};
349-
}
350329
};
351330

352331
SemaOpenACC(Sema &S);

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2159,7 +2159,9 @@ bool ByteCodeExprGen<Emitter>::VisitCXXConstructExpr(
21592159
if (T->isArrayType()) {
21602160
const ConstantArrayType *CAT =
21612161
Ctx.getASTContext().getAsConstantArrayType(E->getType());
2162-
assert(CAT);
2162+
if (!CAT)
2163+
return false;
2164+
21632165
size_t NumElems = CAT->getZExtSize();
21642166
const Function *Func = getFunction(E->getConstructor());
21652167
if (!Func || !Func->isConstexpr())

clang/lib/AST/Interp/Program.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ Descriptor *Program::createDescriptor(const DeclTy &D, const Type *Ty,
386386

387387
// Array of unknown bounds - cannot be accessed and pointer arithmetic
388388
// is forbidden on pointers to such objects.
389-
if (isa<IncompleteArrayType>(ArrayType)) {
389+
if (isa<IncompleteArrayType>(ArrayType) ||
390+
isa<VariableArrayType>(ArrayType)) {
390391
if (std::optional<PrimType> T = Ctx.classify(ElemTy)) {
391392
return allocateDescriptor(D, *T, MDSize, IsTemporary,
392393
Descriptor::UnknownSize{});

clang/lib/AST/OpenACCClause.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
using namespace clang;
1919

2020
bool OpenACCClauseWithParams::classof(const OpenACCClause *C) {
21-
return OpenACCDeviceTypeClause::classof(C) ||
22-
OpenACCClauseWithCondition::classof(C) ||
21+
return OpenACCClauseWithCondition::classof(C) ||
2322
OpenACCClauseWithExprs::classof(C);
2423
}
2524
bool OpenACCClauseWithExprs::classof(const OpenACCClause *C) {
@@ -299,17 +298,6 @@ OpenACCCreateClause::Create(const ASTContext &C, OpenACCClauseKind Spelling,
299298
VarList, EndLoc);
300299
}
301300

302-
OpenACCDeviceTypeClause *OpenACCDeviceTypeClause::Create(
303-
const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc,
304-
SourceLocation LParenLoc, ArrayRef<DeviceTypeArgument> Archs,
305-
SourceLocation EndLoc) {
306-
void *Mem =
307-
C.Allocate(OpenACCDeviceTypeClause::totalSizeToAlloc<DeviceTypeArgument>(
308-
Archs.size()));
309-
return new (Mem)
310-
OpenACCDeviceTypeClause(K, BeginLoc, LParenLoc, Archs, EndLoc);
311-
}
312-
313301
//===----------------------------------------------------------------------===//
314302
// OpenACC clauses printing methods
315303
//===----------------------------------------------------------------------===//
@@ -463,17 +451,3 @@ void OpenACCClausePrinter::VisitWaitClause(const OpenACCWaitClause &C) {
463451
OS << ")";
464452
}
465453
}
466-
467-
void OpenACCClausePrinter::VisitDeviceTypeClause(
468-
const OpenACCDeviceTypeClause &C) {
469-
OS << C.getClauseKind();
470-
OS << "(";
471-
llvm::interleaveComma(C.getArchitectures(), OS,
472-
[&](const DeviceTypeArgument &Arch) {
473-
if (Arch.first == nullptr)
474-
OS << "*";
475-
else
476-
OS << Arch.first;
477-
});
478-
OS << ")";
479-
}

clang/lib/AST/StmtProfile.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,9 +2585,6 @@ void OpenACCClauseProfiler::VisitWaitClause(const OpenACCWaitClause &Clause) {
25852585
for (auto *E : Clause.getQueueIdExprs())
25862586
Profiler.VisitStmt(E);
25872587
}
2588-
/// Nothing to do here, there are no sub-statements.
2589-
void OpenACCClauseProfiler::VisitDeviceTypeClause(
2590-
const OpenACCDeviceTypeClause &Clause) {}
25912588
} // namespace
25922589

25932590
void StmtProfiler::VisitOpenACCComputeConstruct(

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -444,19 +444,6 @@ void TextNodeDumper::Visit(const OpenACCClause *C) {
444444
if (cast<OpenACCWaitClause>(C)->hasQueuesTag())
445445
OS << " has queues tag";
446446
break;
447-
case OpenACCClauseKind::DeviceType:
448-
case OpenACCClauseKind::DType:
449-
OS << "(";
450-
llvm::interleaveComma(
451-
cast<OpenACCDeviceTypeClause>(C)->getArchitectures(), OS,
452-
[&](const DeviceTypeArgument &Arch) {
453-
if (Arch.first == nullptr)
454-
OS << "*";
455-
else
456-
OS << Arch.first->getName();
457-
});
458-
OS << ")";
459-
break;
460447
default:
461448
// Nothing to do here.
462449
break;

clang/lib/Parse/ParseOpenACC.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -711,25 +711,24 @@ bool Parser::ParseOpenACCIntExprList(OpenACCDirectiveKind DK,
711711
/// device_type( device-type-list )
712712
///
713713
/// The device_type clause may be abbreviated to dtype.
714-
bool Parser::ParseOpenACCDeviceTypeList(
715-
llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>> &Archs) {
714+
bool Parser::ParseOpenACCDeviceTypeList() {
716715

717716
if (expectIdentifierOrKeyword(*this)) {
718717
SkipUntil(tok::r_paren, tok::annot_pragma_openacc_end,
719718
Parser::StopBeforeMatch);
720-
return true;
719+
return false;
721720
}
722-
Archs.emplace_back(getCurToken().getIdentifierInfo(), ConsumeToken());
721+
ConsumeToken();
723722

724723
while (!getCurToken().isOneOf(tok::r_paren, tok::annot_pragma_openacc_end)) {
725724
ExpectAndConsume(tok::comma);
726725

727726
if (expectIdentifierOrKeyword(*this)) {
728727
SkipUntil(tok::r_paren, tok::annot_pragma_openacc_end,
729728
Parser::StopBeforeMatch);
730-
return true;
729+
return false;
731730
}
732-
Archs.emplace_back(getCurToken().getIdentifierInfo(), ConsumeToken());
731+
ConsumeToken();
733732
}
734733
return false;
735734
}
@@ -1022,20 +1021,16 @@ Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams(
10221021
break;
10231022
}
10241023
case OpenACCClauseKind::DType:
1025-
case OpenACCClauseKind::DeviceType: {
1026-
llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>> Archs;
1024+
case OpenACCClauseKind::DeviceType:
10271025
if (getCurToken().is(tok::star)) {
10281026
// FIXME: We want to mark that this is an 'everything else' type of
10291027
// device_type in Sema.
1030-
ParsedClause.setDeviceTypeDetails({{nullptr, ConsumeToken()}});
1031-
} else if (!ParseOpenACCDeviceTypeList(Archs)) {
1032-
ParsedClause.setDeviceTypeDetails(std::move(Archs));
1033-
} else {
1028+
ConsumeToken();
1029+
} else if (ParseOpenACCDeviceTypeList()) {
10341030
Parens.skipToEnd();
10351031
return OpenACCCanContinue();
10361032
}
10371033
break;
1038-
}
10391034
case OpenACCClauseKind::Tile:
10401035
if (ParseOpenACCSizeExprList()) {
10411036
Parens.skipToEnd();

clang/lib/Sema/SemaOpenACC.cpp

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -255,33 +255,6 @@ bool checkAlreadyHasClauseOfKind(
255255
return false;
256256
}
257257

258-
/// Implement check from OpenACC3.3: section 2.5.4:
259-
/// Only the async, wait, num_gangs, num_workers, and vector_length clauses may
260-
/// follow a device_type clause.
261-
bool checkValidAfterDeviceType(
262-
SemaOpenACC &S, const OpenACCDeviceTypeClause &DeviceTypeClause,
263-
const SemaOpenACC::OpenACCParsedClause &NewClause) {
264-
// This is only a requirement on compute constructs so far, so this is fine
265-
// otherwise.
266-
if (!isOpenACCComputeDirectiveKind(NewClause.getDirectiveKind()))
267-
return false;
268-
switch (NewClause.getClauseKind()) {
269-
case OpenACCClauseKind::Async:
270-
case OpenACCClauseKind::Wait:
271-
case OpenACCClauseKind::NumGangs:
272-
case OpenACCClauseKind::NumWorkers:
273-
case OpenACCClauseKind::VectorLength:
274-
case OpenACCClauseKind::DType:
275-
case OpenACCClauseKind::DeviceType:
276-
return false;
277-
default:
278-
S.Diag(NewClause.getBeginLoc(), diag::err_acc_clause_after_device_type)
279-
<< NewClause.getClauseKind() << DeviceTypeClause.getClauseKind();
280-
S.Diag(DeviceTypeClause.getBeginLoc(), diag::note_acc_previous_clause_here);
281-
return true;
282-
}
283-
}
284-
285258
} // namespace
286259

287260
SemaOpenACC::SemaOpenACC(Sema &S) : SemaBase(S) {}
@@ -300,17 +273,6 @@ SemaOpenACC::ActOnClause(ArrayRef<const OpenACCClause *> ExistingClauses,
300273
return nullptr;
301274
}
302275

303-
if (const auto *DevTypeClause =
304-
llvm::find_if(ExistingClauses,
305-
[&](const OpenACCClause *C) {
306-
return isa<OpenACCDeviceTypeClause>(C);
307-
});
308-
DevTypeClause != ExistingClauses.end()) {
309-
if (checkValidAfterDeviceType(
310-
*this, *cast<OpenACCDeviceTypeClause>(*DevTypeClause), Clause))
311-
return nullptr;
312-
}
313-
314276
switch (Clause.getClauseKind()) {
315277
case OpenACCClauseKind::Default: {
316278
// Restrictions only properly implemented on 'compute' constructs, and
@@ -689,23 +651,6 @@ SemaOpenACC::ActOnClause(ArrayRef<const OpenACCClause *> ExistingClauses,
689651
Clause.getDevNumExpr(), Clause.getQueuesLoc(), Clause.getQueueIdExprs(),
690652
Clause.getEndLoc());
691653
}
692-
case OpenACCClauseKind::DType:
693-
case OpenACCClauseKind::DeviceType: {
694-
// Restrictions only properly implemented on 'compute' constructs, and
695-
// 'compute' constructs are the only construct that can do anything with
696-
// this yet, so skip/treat as unimplemented in this case.
697-
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
698-
break;
699-
700-
// TODO OpenACC: Once we get enough of the CodeGen implemented that we have
701-
// a source for the list of valid architectures, we need to warn on unknown
702-
// identifiers here.
703-
704-
return OpenACCDeviceTypeClause::Create(
705-
getASTContext(), Clause.getClauseKind(), Clause.getBeginLoc(),
706-
Clause.getLParenLoc(), Clause.getDeviceTypeArchitectures(),
707-
Clause.getEndLoc());
708-
}
709654
default:
710655
break;
711656
}

clang/lib/Sema/TreeTransform.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11480,16 +11480,6 @@ void OpenACCClauseTransform<Derived>::VisitWaitClause(
1148011480
ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
1148111481
ParsedClause.getEndLoc());
1148211482
}
11483-
11484-
template <typename Derived>
11485-
void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
11486-
const OpenACCDeviceTypeClause &C) {
11487-
// Nothing to transform here, just create a new version of 'C'.
11488-
NewClause = OpenACCDeviceTypeClause::Create(
11489-
Self.getSema().getASTContext(), C.getClauseKind(),
11490-
ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11491-
C.getArchitectures(), ParsedClause.getEndLoc());
11492-
}
1149311483
} // namespace
1149411484
template <typename Derived>
1149511485
OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(

0 commit comments

Comments
 (0)