34class DataSharingProcessor {
39 struct OMPConstructSymbolVisitor {
41 : version(ctx.langOptions().OpenMPVersion) {}
47 void Post(
const T &) {}
51 if (isOpenMPPrivatizingConstruct(omp, version))
52 constructs.push_back(&omp);
57 if (isOpenMPPrivatizingConstruct(omp, version))
58 constructs.pop_back();
62 auto current = !constructs.empty() ? constructs.back() : ConstructPtr();
63 symDefMap.try_emplace(name.symbol, current);
67 constructs.push_back(&decl);
72 constructs.pop_back();
89 llvm::DenseMap<semantics::Symbol *, ConstructPtr> symDefMap;
94 mlir::OpBuilder::InsertPoint lastPrivIP;
97 llvm::SetVector<const semantics::Symbol *> explicitlyPrivatizedSymbols;
98 llvm::SetVector<const semantics::Symbol *> defaultSymbols;
99 llvm::SetVector<const semantics::Symbol *> allPrivatizedSymbols;
104 omp::List<omp::Clause> clauses;
106 bool shouldCollectPreDeterminedSymbols;
107 bool useDelayedPrivatization;
108 bool forceHeapAllocationForPrivateDynamicArrays =
false;
109 llvm::SmallPtrSet<const semantics::Symbol *, 16> mightHaveReadHostSym;
111 bool isTargetPrivatization;
112 OMPConstructSymbolVisitor visitor;
115 void collectPrivatizedSymbols(
116 std::optional<semantics::Symbol::Flag> flag,
117 const llvm::SetVector<const semantics::Symbol *> &allSymbols,
118 const llvm::SetVector<const semantics::Symbol *> &symbolsInNestedRegions,
119 llvm::SetVector<const semantics::Symbol *> *symbols =
nullptr);
121 collectSymbols(semantics::Symbol::Flag flag,
122 llvm::SetVector<const semantics::Symbol *> *symbols =
nullptr);
123 void collectSymbolsInNestedRegions(
125 llvm::SetVector<const semantics::Symbol *> &symbolsInNestedRegions);
126 void collectOmpObjectListSymbol(
127 const omp::ObjectList &objects,
128 llvm::SetVector<const semantics::Symbol *> &symbolSet);
129 void collectSymbolsForPrivatization();
130 void insertBarrier(mlir::omp::PrivateClauseOps *clauseOps);
131 void collectDefaultSymbols();
132 void collectImplicitSymbols();
133 void collectPreDeterminedSymbols();
134 void collectIndirectReferences();
135 void privatize(mlir::omp::PrivateClauseOps *clauseOps,
136 std::optional<llvm::omp::Directive> dir = std::nullopt);
137 void copyLastPrivatize(mlir::Operation *op);
138 void insertLastPrivateCompare(mlir::Operation *op);
142 mlir::OpBuilder::InsertPoint *copyAssignIP =
nullptr);
144 mlir::OpBuilder::InsertPoint *lastPrivIP);
145 void insertDeallocs();
154 const List<Clause> &clauses,
156 bool shouldCollectPreDeterminedSymbols,
158 bool isTargetPrivatization =
false);
164 bool isTargetPrivatization =
false);
177 void processStep1(mlir::omp::PrivateClauseOps *clauseOps =
nullptr,
178 std::optional<llvm::omp::Directive> dir = std::nullopt);
179 void processStep2(mlir::Operation *op,
bool isLoop);
181 void pushLoopIV(mlir::Value iv) { loopIVs.push_back(iv); }
183 void setForceHeapAllocationForPrivateDynamicArrays(
bool value =
true) {
184 forceHeapAllocationForPrivateDynamicArrays = value;
187 const llvm::SetVector<const semantics::Symbol *> &
188 getAllSymbolsToPrivatize()
const {
189 return allPrivatizedSymbols;
193 return useDelayedPrivatization
194 ? allPrivatizedSymbols.getArrayRef()
199 mlir::omp::PrivateClauseOps *clauseOps,
200 std::optional<llvm::omp::Directive> dir = std::nullopt);