@@ -26,20 +26,28 @@ void CodeGenFunction::EmitOSSTaskwaitDirective(const OSSTaskwaitDirective &S) {
26
26
CGM.getOmpSsRuntime ().emitTaskwaitCall (*this , S.getBeginLoc ());
27
27
}
28
28
29
+ template <typename DSAKind>
30
+ static void AddDSAData (const OSSTaskDirective &S, SmallVectorImpl<const Expr *> &Data) {
31
+ // All DSA are DeclRefExpr
32
+ llvm::SmallSet<const ValueDecl *, 8 > DeclExpr;
33
+ for (const auto *C : S.getClausesOfKind <DSAKind>()) {
34
+ for (const Expr *Ref : C->varlists ()) {
35
+ if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Ref)) {
36
+ const ValueDecl *VD = DRE->getDecl ();
37
+ if (DeclExpr.insert (VD).second )
38
+ Data.push_back (Ref);
39
+ }
40
+ }
41
+ }
42
+ }
43
+
29
44
void CodeGenFunction::EmitOSSTaskDirective (const OSSTaskDirective &S) {
30
45
OSSTaskDataTy Data;
31
- for (const auto *C : S.getClausesOfKind <OSSSharedClause>()) {
32
- for (const Expr *Ref : C->varlists ())
33
- Data.SharedVars .push_back (Ref);
34
- }
35
- for (const auto *C : S.getClausesOfKind <OSSPrivateClause>()) {
36
- for (const Expr *Ref : C->varlists ())
37
- Data.PrivateVars .push_back (Ref);
38
- }
39
- for (const auto *C : S.getClausesOfKind <OSSFirstprivateClause>()) {
40
- for (const Expr *Ref : C->varlists ())
41
- Data.FirstprivateVars .push_back (Ref);
42
- }
46
+
47
+ AddDSAData<OSSSharedClause>(S, Data.SharedVars );
48
+ AddDSAData<OSSPrivateClause>(S, Data.PrivateVars );
49
+ AddDSAData<OSSFirstprivateClause>(S, Data.FirstprivateVars );
50
+
43
51
for (const auto *C : S.getClausesOfKind <OSSDependClause>()) {
44
52
ArrayRef<OmpSsDependClauseKind> DepKinds = C->getDependencyKind ();
45
53
if (DepKinds.size () == 2 ) {
0 commit comments