36class DataSharingProcessor {
41 struct OMPConstructSymbolVisitor {
43 : version(ctx.langOptions().OpenMPVersion) {}
49 void Post(
const T &) {}
53 if (isOpenMPPrivatizingConstruct(omp, version))
54 constructs.push_back(&omp);
59 if (isOpenMPPrivatizingConstruct(omp, version))
60 constructs.pop_back();
64 auto current = !constructs.empty() ? constructs.back() : ConstructPtr();
65 symDefMap.try_emplace(name.symbol, current);
69 constructs.push_back(&decl);
74 constructs.pop_back();
91 llvm::DenseMap<semantics::Symbol *, ConstructPtr> symDefMap;
96 mlir::OpBuilder::InsertPoint lastPrivIP;
99 llvm::SetVector<const semantics::Symbol *> explicitlyPrivatizedSymbols;
100 llvm::SetVector<const semantics::Symbol *> defaultSymbols;
101 llvm::SetVector<const semantics::Symbol *> allPrivatizedSymbols;
106 omp::List<omp::Clause> clauses;
108 bool shouldCollectPreDeterminedSymbols;
109 bool useDelayedPrivatization;
110 bool forceHeapAllocationForPrivateDynamicArrays =
false;
111 llvm::SmallPtrSet<const semantics::Symbol *, 16> mightHaveReadHostSym;
112 llvm::SmallPtrSet<const semantics::Symbol *, 4>
113 symbolsCoveredByReductionElements;
115 bool isTargetPrivatization;
116 OMPConstructSymbolVisitor visitor;
119 void collectPrivatizedSymbols(
120 std::optional<semantics::Symbol::Flag> flag,
121 const llvm::SetVector<const semantics::Symbol *> &allSymbols,
122 const llvm::SetVector<const semantics::Symbol *> &symbolsInNestedRegions,
123 llvm::SetVector<const semantics::Symbol *> *symbols =
nullptr);
125 collectSymbols(semantics::Symbol::Flag flag,
126 llvm::SetVector<const semantics::Symbol *> *symbols =
nullptr);
127 void collectSymbolsInNestedRegions(
129 llvm::SetVector<const semantics::Symbol *> &symbolsInNestedRegions);
130 void collectOmpObjectListSymbol(
131 const omp::ObjectList &objects,
132 llvm::SetVector<const semantics::Symbol *> &symbolSet);
133 void collectSymbolsForPrivatization();
135 void insertBarrier(mlir::omp::PrivateClauseOps *clauseOps);
136 void collectDefaultSymbols();
137 void collectImplicitSymbols();
138 void collectPreDeterminedSymbols();
139 void collectIndirectReferences();
140 void privatize(mlir::omp::PrivateClauseOps *clauseOps,
141 std::optional<llvm::omp::Directive> dir = std::nullopt);
142 void copyLastPrivatize(mlir::Operation *op);
143 void insertLastPrivateCompare(mlir::Operation *op);
147 mlir::OpBuilder::InsertPoint *copyAssignIP =
nullptr);
149 mlir::OpBuilder::InsertPoint *lastPrivIP);
150 void insertDeallocs();
159 const List<Clause> &clauses,
161 bool shouldCollectPreDeterminedSymbols,
163 bool isTargetPrivatization =
false,
165 symbolsCoveredByReductionElements = {});
171 bool isTargetPrivatization =
false,
173 symbolsCoveredByReductionElements = {});
186 void processStep1(mlir::omp::PrivateClauseOps *clauseOps =
nullptr,
187 std::optional<llvm::omp::Directive> dir = std::nullopt);
188 void processStep2(mlir::Operation *op,
bool isLoop);
190 void pushLoopIV(mlir::Value iv) { loopIVs.push_back(iv); }
192 void setForceHeapAllocationForPrivateDynamicArrays(
bool value =
true) {
193 forceHeapAllocationForPrivateDynamicArrays = value;
196 const llvm::SetVector<const semantics::Symbol *> &
197 getAllSymbolsToPrivatize()
const {
198 return allPrivatizedSymbols;
202 return useDelayedPrivatization
203 ? allPrivatizedSymbols.getArrayRef()
208 mlir::omp::PrivateClauseOps *clauseOps,
209 std::optional<llvm::omp::Directive> dir = std::nullopt);