[flang-commits] [flang] [mlir] [mlir][OpenMP] - MLIR to LLVMIR translation support for delayed privatization of allocatables in `omp.target` ops (PR #116576)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Wed Nov 20 03:11:27 PST 2024
================
@@ -3836,6 +3895,58 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
bool isOffloadEntry =
isTargetDevice || !ompBuilder->Config.TargetTriples.empty();
+ // For some private variables, the MapsForPrivatizedVariablesPass
+ // creates MapInfoOp instances. Go through the private variables and
+ // the mapped variables so that during codegeneration we are able
+ // to quickly look up the corresponding map variable, if any for each
+ // private variable.
+ if (!targetOp.getPrivateVars().empty() && !targetOp.getMapVars().empty()) {
+ auto argIface = llvm::cast<omp::BlockArgOpenMPOpInterface>(*targetOp);
+ OperandRange privateVars = targetOp.getPrivateVars();
+ std::optional<ArrayAttr> privateSyms = targetOp.getPrivateSyms();
+ std::optional<ArrayAttr> privateMapIdices = targetOp.getPrivateMapsAttr();
+
+ for (auto [privVarIdx, privVarSymPair] :
+ llvm::enumerate(llvm::zip_equal(privateVars, *privateSyms))) {
+ auto privVar = std::get<0>(privVarSymPair);
+ auto privSym = std::get<1>(privVarSymPair);
+
+ SymbolRefAttr privatizerName = llvm::cast<SymbolRefAttr>(privSym);
+ omp::PrivateClauseOp privatizer =
+ findPrivatizer(targetOp, privatizerName);
+
+ if (!privatizer.needsMap())
+ continue;
+
+ assert(privateMapIdices.has_value() &&
+ privateMapIdices->size() == privateVars.size());
----------------
tblah wrote:
I think a condition like `if (privateMapIndices.has_value() && (privateMapIndices->size() != privateVars.size())` belongs in the operation verifier
https://github.com/llvm/llvm-project/pull/116576
More information about the flang-commits
mailing list