[Mlir-commits] [mlir] [OpenMP][OMPIRBuilder] Add delayed privatization support for `wsloop` (PR #118463)

Tom Eccles llvmlistbot at llvm.org
Tue Dec 3 04:12:25 PST 2024


================
@@ -1318,6 +1363,85 @@ allocatePrivateVars(llvm::IRBuilderBase &builder,
   return afterAllocas;
 }
 
+static LogicalResult
+initFirstPrivateVars(llvm::IRBuilderBase &builder,
+                     LLVM::ModuleTranslation &moduleTranslation,
+                     SmallVectorImpl<mlir::Value> &mlirPrivateVars,
+                     SmallVectorImpl<llvm::Value *> &llvmPrivateVars,
+                     SmallVectorImpl<omp::PrivateClauseOp> &privateDecls,
+                     llvm::BasicBlock *afterAllocas) {
+  llvm::IRBuilderBase::InsertPointGuard guard(builder);
+  // Apply copy region for firstprivate.
+  bool needsFirstprivate =
+      llvm::any_of(privateDecls, [](omp::PrivateClauseOp &privOp) {
+        return privOp.getDataSharingType() ==
+               omp::DataSharingClauseType::FirstPrivate;
+      });
+
+  if (needsFirstprivate) {
+    // Find the end of the allocation blocks
+    builder.SetInsertPoint(
+        afterAllocas->getSinglePredecessor()->getTerminator());
----------------
tblah wrote:

Please could you add back the assertion you removed here. I liked that it documents the assumption that makes this safe. Otherwise it looks like there's an overlooked bug (if there is more than one predecessor).

https://github.com/llvm/llvm-project/pull/118463


More information about the Mlir-commits mailing list