Skip to content

Commit 93971a4

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:9f858c7b79f9edff082050b930fee347887f8e6d into amd-gfx:d168cedb5f80
Local branch amd-gfx d168ced Merged main:c4e9e41199127bb288e84e9477da99f28941edb3 into amd-gfx:c5f22f9383e1 Remote branch main 9f858c7 [mlir][vector][test] Update tests for vector.xfter_{read|write} (llvm#91943)
2 parents d168ced + 9f858c7 commit 93971a4

Some content is hidden

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

45 files changed

+2917
-749
lines changed

clang/include/clang/AST/OpenACCClause.h

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

20+
#include <utility>
21+
2022
namespace clang {
2123
/// This is the base type for all OpenACC Clauses.
2224
class OpenACCClause {
@@ -75,6 +77,63 @@ class OpenACCClauseWithParams : public OpenACCClause {
7577
}
7678
};
7779

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+
78137
/// A 'default' clause, has the optional 'none' or 'present' argument.
79138
class OpenACCDefaultClause : public OpenACCClauseWithParams {
80139
friend class ASTReaderStmt;

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,13 +1438,18 @@ def err_omp_decl_in_declare_simd_variant : Error<
14381438
def err_omp_sink_and_source_iteration_not_allowd: Error<" '%0 %select{sink:|source:}1' must be with '%select{omp_cur_iteration - 1|omp_cur_iteration}1'">;
14391439
def err_omp_unknown_map_type : Error<
14401440
"incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'">;
1441+
def err_omp_more_one_map_type : Error<"map type is already specified">;
1442+
def note_previous_map_type_specified_here
1443+
: Note<"map type '%0' is previous specified here">;
14411444
def err_omp_unknown_map_type_modifier : Error<
14421445
"incorrect map type modifier, expected one of: 'always', 'close', 'mapper'"
14431446
"%select{|, 'present'|, 'present', 'iterator'}0%select{|, 'ompx_hold'}1">;
14441447
def err_omp_map_type_missing : Error<
14451448
"missing map type">;
14461449
def err_omp_map_type_modifier_missing : Error<
14471450
"missing map type modifier">;
1451+
def err_omp_map_modifier_specification_list : Error<
1452+
"empty modifier-specification-list is not allowed">;
14481453
def err_omp_declare_simd_inbranch_notinbranch : Error<
14491454
"unexpected '%0' clause, '%1' is specified already">;
14501455
def err_omp_expected_clause_argument

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12344,4 +12344,8 @@ 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+
1234712351
} // end of sema component.

clang/include/clang/Basic/OpenACCClauses.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ 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)
4042
VISIT_CLAUSE(FirstPrivate)
4143
VISIT_CLAUSE(If)
4244
VISIT_CLAUSE(NoCreate)

clang/include/clang/Parse/Parser.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3553,6 +3553,23 @@ class Parser : public CodeCompletionHandler {
35533553
OMPClause *ParseOpenMPVarListClause(OpenMPDirectiveKind DKind,
35543554
OpenMPClauseKind Kind, bool ParseOnly);
35553555

3556+
/// Parses a clause consisting of a list of expressions.
3557+
///
3558+
/// \param Kind The clause to parse.
3559+
/// \param ClauseNameLoc [out] The location of the clause name.
3560+
/// \param OpenLoc [out] The location of '('.
3561+
/// \param CloseLoc [out] The location of ')'.
3562+
/// \param Exprs [out] The parsed expressions.
3563+
/// \param ReqIntConst If true, each expression must be an integer constant.
3564+
///
3565+
/// \return Whether the clause was parsed successfully.
3566+
bool ParseOpenMPExprListClause(OpenMPClauseKind Kind,
3567+
SourceLocation &ClauseNameLoc,
3568+
SourceLocation &OpenLoc,
3569+
SourceLocation &CloseLoc,
3570+
SmallVectorImpl<Expr *> &Exprs,
3571+
bool ReqIntConst = false);
3572+
35563573
/// Parses and creates OpenMP 5.0 iterators expression:
35573574
/// <iterators> = 'iterator' '(' { [ <iterator-type> ] identifier =
35583575
/// <range-specification> }+ ')'
@@ -3703,7 +3720,8 @@ class Parser : public CodeCompletionHandler {
37033720
SourceLocation Loc,
37043721
llvm::SmallVectorImpl<Expr *> &IntExprs);
37053722
/// Parses the 'device-type-list', which is a list of identifiers.
3706-
bool ParseOpenACCDeviceTypeList();
3723+
bool ParseOpenACCDeviceTypeList(
3724+
llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>> &Archs);
37073725
/// Parses the 'async-argument', which is an integral value with two
37083726
/// 'special' values that are likely negative (but come from Macros).
37093727
OpenACCIntExprParseResult ParseOpenACCAsyncArgument(OpenACCDirectiveKind DK,

clang/include/clang/Sema/SemaOpenACC.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ 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+
2932
/// A type to represent all the data for an OpenACC Clause that has been
3033
/// parsed, but not yet created/semantically analyzed. This is effectively a
3134
/// discriminated union on the 'Clause Kind', with all of the individual
@@ -60,8 +63,12 @@ class SemaOpenACC : public SemaBase {
6063
SmallVector<Expr *> QueueIdExprs;
6164
};
6265

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

6774
public:
@@ -209,6 +216,13 @@ class SemaOpenACC : public SemaBase {
209216
return std::get<VarListDetails>(Details).IsZero;
210217
}
211218

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+
212226
void setLParenLoc(SourceLocation EndLoc) { LParenLoc = EndLoc; }
213227
void setEndLoc(SourceLocation EndLoc) { ClauseRange.setEnd(EndLoc); }
214228

@@ -326,6 +340,13 @@ class SemaOpenACC : public SemaBase {
326340
"Parsed clause kind does not have a wait-details");
327341
Details = WaitDetails{DevNum, QueuesLoc, std::move(IntExprs)};
328342
}
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+
}
329350
};
330351

331352
SemaOpenACC(Sema &S);

clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -413,22 +413,6 @@ ANALYZER_OPTION(
413413
"analysis is too low, it is meaningful to provide a minimum value that "
414414
"serves as an upper bound instead.", 10000)
415415

416-
ANALYZER_OPTION(
417-
StringRef, CTUPhase1InliningMode, "ctu-phase1-inlining",
418-
"Controls which functions will be inlined during the first phase of the ctu "
419-
"analysis. "
420-
"If the value is set to 'all' then all foreign functions are inlinied "
421-
"immediately during the first phase, thus rendering the second phase a noop. "
422-
"The 'ctu-max-nodes-*' budge has no effect in this case. "
423-
"If the value is 'small' then only functions with a linear CFG and with a "
424-
"limited number of statements would be inlined during the first phase. The "
425-
"long and/or nontrivial functions are handled in the second phase and are "
426-
"controlled by the 'ctu-max-nodes-*' budge. "
427-
"The value 'none' means that all foreign functions are inlined only in the "
428-
"second phase, 'ctu-max-nodes-*' budge limits the second phase. "
429-
"Value: \"none\", \"small\", \"all\".",
430-
"small")
431-
432416
ANALYZER_OPTION(
433417
unsigned, RegionStoreSmallStructLimit, "region-store-small-struct-limit",
434418
"The largest number of fields a struct can have and still be considered "
@@ -478,6 +462,22 @@ ANALYZER_OPTION(
478462
"where to look for those alternative implementations (called models).",
479463
"")
480464

465+
ANALYZER_OPTION(
466+
StringRef, CTUPhase1InliningMode, "ctu-phase1-inlining",
467+
"Controls which functions will be inlined during the first phase of the ctu "
468+
"analysis. "
469+
"If the value is set to 'all' then all foreign functions are inlinied "
470+
"immediately during the first phase, thus rendering the second phase a noop. "
471+
"The 'ctu-max-nodes-*' budge has no effect in this case. "
472+
"If the value is 'small' then only functions with a linear CFG and with a "
473+
"limited number of statements would be inlined during the first phase. The "
474+
"long and/or nontrivial functions are handled in the second phase and are "
475+
"controlled by the 'ctu-max-nodes-*' budge. "
476+
"The value 'none' means that all foreign functions are inlined only in the "
477+
"second phase, 'ctu-max-nodes-*' budge limits the second phase. "
478+
"Value: \"none\", \"small\", \"all\".",
479+
"small")
480+
481481
ANALYZER_OPTION(
482482
StringRef, CXXMemberInliningMode, "c++-inlining",
483483
"Controls which C++ member functions will be considered for inlining. "

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,8 @@ bool ByteCodeExprGen<Emitter>::visitExpr(const Expr *E) {
28612861
return this->emitRetValue(E) && RootScope.destroyLocals();
28622862
}
28632863

2864-
return RootScope.destroyLocals();
2864+
RootScope.destroyLocals();
2865+
return false;
28652866
}
28662867

28672868
/// Toplevel visitDecl().

clang/lib/AST/OpenACCClause.cpp

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

2020
bool OpenACCClauseWithParams::classof(const OpenACCClause *C) {
21-
return OpenACCClauseWithCondition::classof(C) ||
21+
return OpenACCDeviceTypeClause::classof(C) ||
22+
OpenACCClauseWithCondition::classof(C) ||
2223
OpenACCClauseWithExprs::classof(C);
2324
}
2425
bool OpenACCClauseWithExprs::classof(const OpenACCClause *C) {
@@ -298,6 +299,17 @@ OpenACCCreateClause::Create(const ASTContext &C, OpenACCClauseKind Spelling,
298299
VarList, EndLoc);
299300
}
300301

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+
301313
//===----------------------------------------------------------------------===//
302314
// OpenACC clauses printing methods
303315
//===----------------------------------------------------------------------===//
@@ -451,3 +463,17 @@ void OpenACCClausePrinter::VisitWaitClause(const OpenACCWaitClause &C) {
451463
OS << ")";
452464
}
453465
}
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,6 +2585,9 @@ 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) {}
25882591
} // namespace
25892592

25902593
void StmtProfiler::VisitOpenACCComputeConstruct(

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,19 @@ 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;
447460
default:
448461
// Nothing to do here.
449462
break;

clang/lib/Parse/ParseOpenACC.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -711,24 +711,25 @@ 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() {
714+
bool Parser::ParseOpenACCDeviceTypeList(
715+
llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>> &Archs) {
715716

716717
if (expectIdentifierOrKeyword(*this)) {
717718
SkipUntil(tok::r_paren, tok::annot_pragma_openacc_end,
718719
Parser::StopBeforeMatch);
719-
return false;
720+
return true;
720721
}
721-
ConsumeToken();
722+
Archs.emplace_back(getCurToken().getIdentifierInfo(), ConsumeToken());
722723

723724
while (!getCurToken().isOneOf(tok::r_paren, tok::annot_pragma_openacc_end)) {
724725
ExpectAndConsume(tok::comma);
725726

726727
if (expectIdentifierOrKeyword(*this)) {
727728
SkipUntil(tok::r_paren, tok::annot_pragma_openacc_end,
728729
Parser::StopBeforeMatch);
729-
return false;
730+
return true;
730731
}
731-
ConsumeToken();
732+
Archs.emplace_back(getCurToken().getIdentifierInfo(), ConsumeToken());
732733
}
733734
return false;
734735
}
@@ -1021,16 +1022,20 @@ Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams(
10211022
break;
10221023
}
10231024
case OpenACCClauseKind::DType:
1024-
case OpenACCClauseKind::DeviceType:
1025+
case OpenACCClauseKind::DeviceType: {
1026+
llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>> Archs;
10251027
if (getCurToken().is(tok::star)) {
10261028
// FIXME: We want to mark that this is an 'everything else' type of
10271029
// device_type in Sema.
1028-
ConsumeToken();
1029-
} else if (ParseOpenACCDeviceTypeList()) {
1030+
ParsedClause.setDeviceTypeDetails({{nullptr, ConsumeToken()}});
1031+
} else if (!ParseOpenACCDeviceTypeList(Archs)) {
1032+
ParsedClause.setDeviceTypeDetails(std::move(Archs));
1033+
} else {
10301034
Parens.skipToEnd();
10311035
return OpenACCCanContinue();
10321036
}
10331037
break;
1038+
}
10341039
case OpenACCClauseKind::Tile:
10351040
if (ParseOpenACCSizeExprList()) {
10361041
Parens.skipToEnd();

0 commit comments

Comments
 (0)