[Mlir-commits] [mlir] [MLIR][OpenMP] Support basic materialization for `omp.private` ops (PR #81715)
Sergio Afonso
llvmlistbot at llvm.org
Wed Feb 21 02:59:36 PST 2024
================
@@ -1000,11 +1011,39 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
return success();
}
+/// Replace the region arguments of the parallel op (which correspond to private
+/// variables) with the actual private variables they correspond to. This
+/// prepares the parallel op so that it matches what is expected by the
+/// OMPIRBuilder. Instead of editing the original op in-place, this function
+/// does the required changes to a cloned version which should then be erased by
+/// the caller.
+static omp::ParallelOp
+prepareOmpParallelForPrivatization(omp::ParallelOp opInst) {
+ mlir::OpBuilder cloneBuilder(opInst);
+ omp::ParallelOp opInstClone =
+ llvm::cast<omp::ParallelOp>(cloneBuilder.clone(*opInst));
----------------
skatrak wrote:
There's a variant of the `OpBuilder::clone` method that also takes an `IRMapping` object. Maybe it would be easier to set that up than the code below manually replacing all uses of block arguments.
This feedback is only in the case that other reviewer's suggestions of making changes to the OMPIRBuilder instead is eventually agreed to not be a better solution.
https://github.com/llvm/llvm-project/pull/81715
More information about the Mlir-commits
mailing list