[flang-commits] [flang] [mlir] [OpenMP][flang][MLIR] Decouple alloc, init, and copy regions for `omp.private|declare_reduction` ops (PR #125699)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Wed Feb 5 06:19:44 PST 2025


================
@@ -1331,18 +1336,15 @@ findAssociatedValue(Value privateVar, llvm::IRBuilderBase &builder,
 
 /// Initialize a single (first)private variable. You probably want to use
 /// allocateAndInitPrivateVars instead of this.
-static llvm::Error
-initPrivateVar(llvm::IRBuilderBase &builder,
-               LLVM::ModuleTranslation &moduleTranslation,
-               omp::PrivateClauseOp &privDecl, Value mlirPrivVar,
-               BlockArgument &blockArg, llvm::Value *llvmPrivateVar,
-               llvm::SmallVectorImpl<llvm::Value *> &llvmPrivateVars,
-               llvm::BasicBlock *privInitBlock,
-               llvm::DenseMap<Value, Value> *mappedPrivateVars = nullptr) {
+static llvm::Error initPrivateVar(
+    llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation,
+    omp::PrivateClauseOp &privDecl, Value mlirPrivVar, BlockArgument &blockArg,
+    llvm::SmallVectorImpl<llvm::Value *>::iterator llvmPrivateVarIt,
----------------
ergawy wrote:

This is just the least disruptive solution I could find to extract the logic now in `initPrivateVars` to a separate function (previously this was in `allocateAndInitPrivateVars`). Since `allocatePrivateVars` fills `llvmPrivateVars` and `initPrivateVars` updates some of its items (with the `phi` results), I passed the iterators so that we can modify the elements we need to modify.

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


More information about the flang-commits mailing list