@@ -62,15 +62,14 @@ class DSAStackTy {
62
62
struct DSAVarData {
63
63
OpenMPDirectiveKind DKind = OMPD_unknown;
64
64
OpenMPClauseKind CKind = OMPC_unknown;
65
- unsigned Modifier = 0;
66
65
const Expr *RefExpr = nullptr;
67
66
DeclRefExpr *PrivateCopy = nullptr;
68
67
SourceLocation ImplicitDSALoc;
69
68
DSAVarData() = default;
70
69
DSAVarData(OpenMPDirectiveKind DKind, OpenMPClauseKind CKind,
71
70
const Expr *RefExpr, DeclRefExpr *PrivateCopy,
72
- SourceLocation ImplicitDSALoc, unsigned Modifier )
73
- : DKind(DKind), CKind(CKind), Modifier(Modifier), RefExpr(RefExpr),
71
+ SourceLocation ImplicitDSALoc)
72
+ : DKind(DKind), CKind(CKind), RefExpr(RefExpr),
74
73
PrivateCopy(PrivateCopy), ImplicitDSALoc(ImplicitDSALoc) {}
75
74
};
76
75
using OperatorOffsetTy =
@@ -81,7 +80,6 @@ class DSAStackTy {
81
80
private:
82
81
struct DSAInfo {
83
82
OpenMPClauseKind Attributes = OMPC_unknown;
84
- unsigned Modifier = 0;
85
83
/// Pointer to a reference expression and a flag which shows that the
86
84
/// variable is marked as lastprivate(true) or not (false).
87
85
llvm::PointerIntPair<const Expr *, 1, bool> RefExpr;
@@ -166,8 +164,6 @@ class DSAStackTy {
166
164
/// List of globals marked as declare target link in this target region
167
165
/// (isOpenMPTargetExecutionDirective(Directive) == true).
168
166
llvm::SmallVector<DeclRefExpr *, 4> DeclareTargetLinkVarDecls;
169
- /// List of decls used in inclusive/exclusive clauses of the scan directive.
170
- llvm::DenseSet<CanonicalDeclPtr<Decl>> UsedInScanDirective;
171
167
SharingMapTy(OpenMPDirectiveKind DKind, DeclarationNameInfo Name,
172
168
Scope *CurScope, SourceLocation Loc)
173
169
: Directive(DKind), DirectiveName(Name), CurScope(CurScope),
@@ -473,20 +469,9 @@ class DSAStackTy {
473
469
/// parent directive.
474
470
const ValueDecl *getParentLoopControlVariable(unsigned I) const;
475
471
476
- /// Marks the specified decl \p D as used in scan directive.
477
- void markDeclAsUsedInScanDirective(ValueDecl *D) {
478
- if (SharingMapTy *Stack = getSecondOnStackOrNull())
479
- Stack->UsedInScanDirective.insert(D);
480
- }
481
-
482
- /// Checks if the specified declaration was used in the inner scan directive.
483
- bool isUsedInScanDirective(ValueDecl *D) const {
484
- return getTopOfStack().UsedInScanDirective.count(D) > 0;
485
- }
486
-
487
472
/// Adds explicit data sharing attribute to the specified declaration.
488
473
void addDSA(const ValueDecl *D, const Expr *E, OpenMPClauseKind A,
489
- DeclRefExpr *PrivateCopy = nullptr, unsigned Modifier = 0 );
474
+ DeclRefExpr *PrivateCopy = nullptr);
490
475
491
476
/// Adds additional information for the reduction items with the reduction id
492
477
/// represented as an operator.
@@ -1094,7 +1079,6 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(const_iterator &Iter,
1094
1079
DVar.PrivateCopy = Data.PrivateCopy;
1095
1080
DVar.CKind = Data.Attributes;
1096
1081
DVar.ImplicitDSALoc = Iter->DefaultAttrLoc;
1097
- DVar.Modifier = Data.Modifier;
1098
1082
return DVar;
1099
1083
}
1100
1084
@@ -1242,21 +1226,19 @@ const ValueDecl *DSAStackTy::getParentLoopControlVariable(unsigned I) const {
1242
1226
}
1243
1227
1244
1228
void DSAStackTy::addDSA(const ValueDecl *D, const Expr *E, OpenMPClauseKind A,
1245
- DeclRefExpr *PrivateCopy, unsigned Modifier ) {
1229
+ DeclRefExpr *PrivateCopy) {
1246
1230
D = getCanonicalDecl(D);
1247
1231
if (A == OMPC_threadprivate) {
1248
1232
DSAInfo &Data = Threadprivates[D];
1249
1233
Data.Attributes = A;
1250
1234
Data.RefExpr.setPointer(E);
1251
1235
Data.PrivateCopy = nullptr;
1252
- Data.Modifier = Modifier;
1253
1236
} else {
1254
1237
DSAInfo &Data = getTopOfStack().SharingMap[D];
1255
1238
assert(Data.Attributes == OMPC_unknown || (A == Data.Attributes) ||
1256
1239
(A == OMPC_firstprivate && Data.Attributes == OMPC_lastprivate) ||
1257
1240
(A == OMPC_lastprivate && Data.Attributes == OMPC_firstprivate) ||
1258
1241
(isLoopControlVariable(D).first && A == OMPC_private));
1259
- Data.Modifier = Modifier;
1260
1242
if (A == OMPC_lastprivate && Data.Attributes == OMPC_firstprivate) {
1261
1243
Data.RefExpr.setInt(/*IntVal=*/true);
1262
1244
return;
@@ -1268,7 +1250,6 @@ void DSAStackTy::addDSA(const ValueDecl *D, const Expr *E, OpenMPClauseKind A,
1268
1250
Data.PrivateCopy = PrivateCopy;
1269
1251
if (PrivateCopy) {
1270
1252
DSAInfo &Data = getTopOfStack().SharingMap[PrivateCopy->getDecl()];
1271
- Data.Modifier = Modifier;
1272
1253
Data.Attributes = A;
1273
1254
Data.RefExpr.setPointerAndInt(PrivateCopy, IsLastprivate);
1274
1255
Data.PrivateCopy = nullptr;
@@ -1374,7 +1355,7 @@ const DSAStackTy::DSAVarData DSAStackTy::getTopMostTaskgroupReductionData(
1374
1355
"set.");
1375
1356
TaskgroupDescriptor = I->TaskgroupReductionRef;
1376
1357
return DSAVarData(OMPD_taskgroup, OMPC_reduction, Data.RefExpr.getPointer(),
1377
- Data.PrivateCopy, I->DefaultAttrLoc, /*Modifier=*/0 );
1358
+ Data.PrivateCopy, I->DefaultAttrLoc);
1378
1359
}
1379
1360
return DSAVarData();
1380
1361
}
@@ -1399,7 +1380,7 @@ const DSAStackTy::DSAVarData DSAStackTy::getTopMostTaskgroupReductionData(
1399
1380
"set.");
1400
1381
TaskgroupDescriptor = I->TaskgroupReductionRef;
1401
1382
return DSAVarData(OMPD_taskgroup, OMPC_reduction, Data.RefExpr.getPointer(),
1402
- Data.PrivateCopy, I->DefaultAttrLoc, /*Modifier=*/0 );
1383
+ Data.PrivateCopy, I->DefaultAttrLoc);
1403
1384
}
1404
1385
return DSAVarData();
1405
1386
}
@@ -1474,7 +1455,6 @@ const DSAStackTy::DSAVarData DSAStackTy::getTopDSA(ValueDecl *D,
1474
1455
if (TI != Threadprivates.end()) {
1475
1456
DVar.RefExpr = TI->getSecond().RefExpr.getPointer();
1476
1457
DVar.CKind = OMPC_threadprivate;
1477
- DVar.Modifier = TI->getSecond().Modifier;
1478
1458
return DVar;
1479
1459
}
1480
1460
if (VD && VD->hasAttr<OMPThreadPrivateDeclAttr>()) {
@@ -1566,7 +1546,6 @@ const DSAStackTy::DSAVarData DSAStackTy::getTopDSA(ValueDecl *D,
1566
1546
DVar.CKind = Data.Attributes;
1567
1547
DVar.ImplicitDSALoc = I->DefaultAttrLoc;
1568
1548
DVar.DKind = I->Directive;
1569
- DVar.Modifier = Data.Modifier;
1570
1549
return DVar;
1571
1550
}
1572
1551
@@ -1613,7 +1592,6 @@ const DSAStackTy::DSAVarData DSAStackTy::getTopDSA(ValueDecl *D,
1613
1592
DVar.CKind = Data.Attributes;
1614
1593
DVar.ImplicitDSALoc = I->DefaultAttrLoc;
1615
1594
DVar.DKind = I->Directive;
1616
- DVar.Modifier = Data.Modifier;
1617
1595
}
1618
1596
1619
1597
return DVar;
@@ -2337,64 +2315,11 @@ void Sema::EndOpenMPClause() {
2337
2315
DSAStack->setClauseParsingMode(/*K=*/OMPC_unknown);
2338
2316
}
2339
2317
2318
+ static void checkAllocateClauses(Sema &S, DSAStackTy *Stack,
2319
+ ArrayRef<OMPClause *> Clauses);
2340
2320
static std::pair<ValueDecl *, bool>
2341
2321
getPrivateItem(Sema &S, Expr *&RefExpr, SourceLocation &ELoc,
2342
2322
SourceRange &ERange, bool AllowArraySection = false);
2343
-
2344
- /// Check consistency of the reduction clauses.
2345
- static void checkReductionClauses(Sema &S, DSAStackTy *Stack,
2346
- ArrayRef<OMPClause *> Clauses) {
2347
- bool InscanFound = false;
2348
- SourceLocation InscanLoc;
2349
- // OpenMP 5.0, 2.19.5.4 reduction Clause, Restrictions.
2350
- // A reduction clause without the inscan reduction-modifier may not appear on
2351
- // a construct on which a reduction clause with the inscan reduction-modifier
2352
- // appears.
2353
- for (OMPClause *C : Clauses) {
2354
- if (C->getClauseKind() != OMPC_reduction)
2355
- continue;
2356
- auto *RC = cast<OMPReductionClause>(C);
2357
- if (RC->getModifier() == OMPC_REDUCTION_inscan) {
2358
- InscanFound = true;
2359
- InscanLoc = RC->getModifierLoc();
2360
- break;
2361
- }
2362
- }
2363
- if (InscanFound) {
2364
- for (OMPClause *C : Clauses) {
2365
- if (C->getClauseKind() != OMPC_reduction)
2366
- continue;
2367
- auto *RC = cast<OMPReductionClause>(C);
2368
- if (RC->getModifier() != OMPC_REDUCTION_inscan) {
2369
- S.Diag(RC->getModifier() == OMPC_REDUCTION_unknown
2370
- ? RC->getBeginLoc()
2371
- : RC->getModifierLoc(),
2372
- diag::err_omp_inscan_reduction_expected);
2373
- S.Diag(InscanLoc, diag::note_omp_previous_inscan_reduction);
2374
- continue;
2375
- }
2376
- for (Expr *Ref : RC->varlists()) {
2377
- assert(Ref && "NULL expr in OpenMP nontemporal clause.");
2378
- SourceLocation ELoc;
2379
- SourceRange ERange;
2380
- Expr *SimpleRefExpr = Ref;
2381
- auto Res = getPrivateItem(S, SimpleRefExpr, ELoc, ERange,
2382
- /*AllowArraySection=*/true);
2383
- ValueDecl *D = Res.first;
2384
- if (!D)
2385
- continue;
2386
- if (!Stack->isUsedInScanDirective(getCanonicalDecl(D))) {
2387
- S.Diag(Ref->getExprLoc(),
2388
- diag::err_omp_reduction_not_inclusive_exclusive)
2389
- << Ref->getSourceRange();
2390
- }
2391
- }
2392
- }
2393
- }
2394
- }
2395
-
2396
- static void checkAllocateClauses(Sema &S, DSAStackTy *Stack,
2397
- ArrayRef<OMPClause *> Clauses);
2398
2323
static DeclRefExpr *buildCapture(Sema &S, ValueDecl *D, Expr *CaptureExpr,
2399
2324
bool WithInit);
2400
2325
@@ -2471,7 +2396,6 @@ void Sema::EndOpenMPDSABlock(Stmt *CurDirective) {
2471
2396
// Check allocate clauses.
2472
2397
if (!CurContext->isDependentContext())
2473
2398
checkAllocateClauses(*this, DSAStack, D->clauses());
2474
- checkReductionClauses(*this, DSAStack, D->clauses());
2475
2399
}
2476
2400
2477
2401
DSAStack->pop();
@@ -14187,11 +14111,9 @@ struct ReductionData {
14187
14111
SmallVector<Decl *, 4> ExprCaptures;
14188
14112
/// List of postupdate expressions.
14189
14113
SmallVector<Expr *, 4> ExprPostUpdates;
14190
- /// Reduction modifier.
14191
- unsigned RedModifier = 0;
14192
14114
ReductionData() = delete;
14193
14115
/// Reserves required memory for the reduction data.
14194
- ReductionData(unsigned Size, unsigned Modifier = 0) : RedModifier(Modifier ) {
14116
+ ReductionData(unsigned Size) {
14195
14117
Vars.reserve(Size);
14196
14118
Privates.reserve(Size);
14197
14119
LHSs.reserve(Size);
@@ -14909,8 +14831,7 @@ static bool actOnOMPReductionKindClause(
14909
14831
}
14910
14832
// All reduction items are still marked as reduction (to do not increase
14911
14833
// code base size).
14912
- Stack->addDSA(D, RefExpr->IgnoreParens(), OMPC_reduction, Ref,
14913
- RD.RedModifier);
14834
+ Stack->addDSA(D, RefExpr->IgnoreParens(), OMPC_reduction, Ref);
14914
14835
if (CurrDir == OMPD_taskgroup) {
14915
14836
if (DeclareReductionRef.isUsable())
14916
14837
Stack->addTaskgroupReductionData(D, ReductionIdRange,
@@ -14937,22 +14858,8 @@ OMPClause *Sema::ActOnOpenMPReductionClause(
14937
14858
<< getOpenMPClauseName(OMPC_reduction);
14938
14859
return nullptr;
14939
14860
}
14940
- // OpenMP 5.0, 2.19.5.4 reduction Clause, Restrictions
14941
- // A reduction clause with the inscan reduction-modifier may only appear on a
14942
- // worksharing-loop construct, a worksharing-loop SIMD construct, a simd
14943
- // construct, a parallel worksharing-loop construct or a parallel
14944
- // worksharing-loop SIMD construct.
14945
- if (Modifier == OMPC_REDUCTION_inscan &&
14946
- (DSAStack->getCurrentDirective() != OMPD_for &&
14947
- DSAStack->getCurrentDirective() != OMPD_for_simd &&
14948
- DSAStack->getCurrentDirective() != OMPD_simd &&
14949
- DSAStack->getCurrentDirective() != OMPD_parallel_for &&
14950
- DSAStack->getCurrentDirective() != OMPD_parallel_for_simd)) {
14951
- Diag(ModifierLoc, diag::err_omp_wrong_inscan_reduction);
14952
- return nullptr;
14953
- }
14954
14861
14955
- ReductionData RD(VarList.size(), Modifier );
14862
+ ReductionData RD(VarList.size());
14956
14863
if (actOnOMPReductionKindClause(*this, DSAStack, OMPC_reduction, VarList,
14957
14864
StartLoc, LParenLoc, ColonLoc, EndLoc,
14958
14865
ReductionIdScopeSpec, ReductionId,
@@ -18254,19 +18161,6 @@ OMPClause *Sema::ActOnOpenMPInclusiveClause(ArrayRef<Expr *> VarList,
18254
18161
if (!D)
18255
18162
continue;
18256
18163
18257
- const DSAStackTy::DSAVarData DVar =
18258
- DSAStack->getTopDSA(D, /*FromParent=*/true);
18259
- // OpenMP 5.0, 2.9.6, scan Directive, Restrictions.
18260
- // A list item that appears in the inclusive or exclusive clause must appear
18261
- // in a reduction clause with the inscan modifier on the enclosing
18262
- // worksharing-loop, worksharing-loop SIMD, or simd construct.
18263
- if (DVar.CKind != OMPC_reduction ||
18264
- DVar.Modifier != OMPC_REDUCTION_inscan)
18265
- Diag(ELoc, diag::err_omp_inclusive_exclusive_not_reduction)
18266
- << RefExpr->getSourceRange();
18267
-
18268
- if (DSAStack->getParentDirective() != OMPD_unknown)
18269
- DSAStack->markDeclAsUsedInScanDirective(D);
18270
18164
Vars.push_back(RefExpr);
18271
18165
}
18272
18166
@@ -18295,19 +18189,6 @@ OMPClause *Sema::ActOnOpenMPExclusiveClause(ArrayRef<Expr *> VarList,
18295
18189
if (!D)
18296
18190
continue;
18297
18191
18298
- const DSAStackTy::DSAVarData DVar =
18299
- DSAStack->getTopDSA(D, /*FromParent=*/true);
18300
- // OpenMP 5.0, 2.9.6, scan Directive, Restrictions.
18301
- // A list item that appears in the inclusive or exclusive clause must appear
18302
- // in a reduction clause with the inscan modifier on the enclosing
18303
- // worksharing-loop, worksharing-loop SIMD, or simd construct.
18304
- if (DVar.CKind != OMPC_reduction ||
18305
- DVar.Modifier != OMPC_REDUCTION_inscan)
18306
- Diag(ELoc, diag::err_omp_inclusive_exclusive_not_reduction)
18307
- << RefExpr->getSourceRange();
18308
-
18309
- if (DSAStack->getParentDirective() != OMPD_unknown)
18310
- DSAStack->markDeclAsUsedInScanDirective(D);
18311
18192
Vars.push_back(RefExpr);
18312
18193
}
18313
18194
0 commit comments