@@ -264,6 +264,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
264
264
Stmt *CS = nullptr ;
265
265
llvm::SmallVector<Expr *, 4 > ImplicitShared;
266
266
llvm::SmallVector<Expr *, 4 > ImplicitFirstprivate;
267
+ llvm::SmallSet<const ValueDecl *, 4 > InnerDecls;
267
268
268
269
public:
269
270
void VisitDeclRefExpr (DeclRefExpr *E) {
@@ -273,18 +274,24 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
273
274
if (auto *VD = dyn_cast<VarDecl>(E->getDecl ())) {
274
275
VD = VD->getCanonicalDecl ();
275
276
277
+ // Variables declared inside region don't have DSA
278
+ if (InnerDecls.count (VD))
279
+ return ;
280
+
276
281
DSAStackTy::DSAVarData DVarCurrent = Stack->getCurrentDSA (VD);
277
282
DSAStackTy::DSAVarData DVarFromParent = Stack->getTopDSA (VD, /* FromParent=*/ true );
278
283
279
- bool IsParentExplicit = DVarFromParent.RefExpr && !DVarFromParent. Ignore ;
280
- bool IsCurrentExplicit = DVarCurrent. RefExpr && !DVarCurrent .Ignore ;
284
+ bool ExistsParent = DVarFromParent.RefExpr ;
285
+ bool ParentIgnore = DVarFromParent .Ignore ;
281
286
282
- // Check if the variable has explicit DSA only set on the current
287
+ bool ExistsCurrent = DVarCurrent.RefExpr ;
288
+
289
+ // Check if the variable has DSA set on the current
283
290
// directive and stop analysis if it so.
284
- if (IsCurrentExplicit )
291
+ if (ExistsCurrent )
285
292
return ;
286
293
// If explicit DSA comes from parent inherit it
287
- if (IsParentExplicit ) {
294
+ if (ExistsParent && !ParentIgnore ) {
288
295
switch (DVarFromParent.CKind ) {
289
296
case OSSC_shared:
290
297
ImplicitShared.push_back (E);
@@ -309,6 +316,8 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
309
316
// Define implicit data-sharing attributes for task.
310
317
if (isOmpSsTaskingDirective (DKind))
311
318
ImplicitShared.push_back (E);
319
+ // Record DSA as Ignored to avoid making the same node again
320
+ Stack->addDSA (VD, E, OSSC_shared, /* Ignore=*/ true );
312
321
break ;
313
322
case DSA_none:
314
323
if (!DVarCurrent.Ignore ) {
@@ -326,13 +335,19 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
326
335
// Define implicit data-sharing attributes for task.
327
336
if (isOmpSsTaskingDirective (DKind))
328
337
ImplicitFirstprivate.push_back (E);
338
+
339
+ // Record DSA as Ignored to avoid making the same node again
340
+ Stack->addDSA (VD, E, OSSC_firstprivate, /* Ignore=*/ true );
329
341
} else {
330
342
// If no default clause is present and the variable was shared/global
331
343
// in the context encountering the construct, the variable will be shared.
332
344
333
345
// Define implicit data-sharing attributes for task.
334
346
if (isOmpSsTaskingDirective (DKind))
335
347
ImplicitShared.push_back (E);
348
+
349
+ // Record DSA as Ignored to avoid making the same node again
350
+ Stack->addDSA (VD, E, OSSC_shared, /* Ignore=*/ true );
336
351
}
337
352
}
338
353
}
@@ -346,6 +361,12 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
346
361
}
347
362
}
348
363
364
+ void VisitDeclStmt (DeclStmt *S) {
365
+ for (const Decl *D : S->decls ())
366
+ if (const auto *VD = dyn_cast_or_null<ValueDecl>(D))
367
+ InnerDecls.insert (VD);
368
+ }
369
+
349
370
bool isErrorFound () const { return ErrorFound; }
350
371
351
372
ArrayRef<Expr *> getImplicitShared () const {
0 commit comments