[Mlir-commits] [mlir] b7eb01b - [NFC][OpenMP][MLIR] Refactor code related to collecting privatizer info into a shared util (#131582)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Mar 19 04:06:37 PDT 2025
Author: Kareem Ergawy
Date: 2025-03-19T12:06:33+01:00
New Revision: b7eb01b3a15d59be58319705c916ddf6859d0aab
URL: https://github.com/llvm/llvm-project/commit/b7eb01b3a15d59be58319705c916ddf6859d0aab
DIFF: https://github.com/llvm/llvm-project/commit/b7eb01b3a15d59be58319705c916ddf6859d0aab.diff
LOG: [NFC][OpenMP][MLIR] Refactor code related to collecting privatizer info into a shared util (#131582)
Moves code needed to collect info about delayed privatizers into a
shared util instread of repeating the same patter across all relevant
constructs.
Added:
Modified:
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 88d2e56e2f36e..722107c7ec6d7 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -704,20 +704,41 @@ convertOmpCritical(Operation &opInst, llvm::IRBuilderBase &builder,
return success();
}
-/// Populates `privatizations` with privatization declarations used for the
-/// given op.
-template <class OP>
-static void collectPrivatizationDecls(
- OP op, SmallVectorImpl<omp::PrivateClauseOp> &privatizations) {
- std::optional<ArrayAttr> attr = op.getPrivateSyms();
- if (!attr)
- return;
+/// A util to collect info needed to convert delayed privatizers from MLIR to
+/// LLVM.
+struct PrivateVarsInfo {
+ template <typename OP>
+ PrivateVarsInfo(OP op)
+ : blockArgs(
+ cast<omp::BlockArgOpenMPOpInterface>(*op).getPrivateBlockArgs()) {
+ mlirVars.reserve(blockArgs.size());
+ llvmVars.reserve(blockArgs.size());
+ collectPrivatizationDecls<OP>(op);
+
+ for (mlir::Value privateVar : op.getPrivateVars())
+ mlirVars.push_back(privateVar);
+ }
- privatizations.reserve(privatizations.size() + attr->size());
- for (auto symbolRef : attr->getAsRange<SymbolRefAttr>()) {
- privatizations.push_back(findPrivatizer(op, symbolRef));
+ MutableArrayRef<BlockArgument> blockArgs;
+ SmallVector<mlir::Value> mlirVars;
+ SmallVector<llvm::Value *> llvmVars;
+ SmallVector<omp::PrivateClauseOp> privatizers;
+
+private:
+ /// Populates `privatizations` with privatization declarations used for the
+ /// given op.
+ template <class OP>
+ void collectPrivatizationDecls(OP op) {
+ std::optional<ArrayAttr> attr = op.getPrivateSyms();
+ if (!attr)
+ return;
+
+ privatizers.reserve(privatizers.size() + attr->size());
+ for (auto symbolRef : attr->getAsRange<SymbolRefAttr>()) {
+ privatizers.push_back(findPrivatizer(op, symbolRef));
+ }
}
-}
+};
/// Populates `reductions` with reduction declarations used in the given op.
template <typename T>
@@ -1392,19 +1413,17 @@ static llvm::Expected<llvm::Value *> initPrivateVar(
static llvm::Error
initPrivateVars(llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation,
- MutableArrayRef<BlockArgument> privateBlockArgs,
- MutableArrayRef<omp::PrivateClauseOp> privateDecls,
- MutableArrayRef<mlir::Value> mlirPrivateVars,
- llvm::SmallVectorImpl<llvm::Value *> &llvmPrivateVars,
+ PrivateVarsInfo &privateVarsInfo,
llvm::DenseMap<Value, Value> *mappedPrivateVars = nullptr) {
- if (privateBlockArgs.empty())
+ if (privateVarsInfo.blockArgs.empty())
return llvm::Error::success();
llvm::BasicBlock *privInitBlock = splitBB(builder, true, "omp.private.init");
setInsertPointForPossiblyEmptyBlock(builder, privInitBlock);
for (auto [idx, zip] : llvm::enumerate(llvm::zip_equal(
- privateDecls, mlirPrivateVars, privateBlockArgs, llvmPrivateVars))) {
+ privateVarsInfo.privatizers, privateVarsInfo.mlirVars,
+ privateVarsInfo.blockArgs, privateVarsInfo.llvmVars))) {
auto [privDecl, mlirPrivVar, blockArg, llvmPrivateVar] = zip;
llvm::Expected<llvm::Value *> privVarOrErr = initPrivateVar(
builder, moduleTranslation, privDecl, mlirPrivVar, blockArg,
@@ -1428,10 +1447,7 @@ initPrivateVars(llvm::IRBuilderBase &builder,
static llvm::Expected<llvm::BasicBlock *>
allocatePrivateVars(llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation,
- MutableArrayRef<BlockArgument> privateBlockArgs,
- MutableArrayRef<omp::PrivateClauseOp> privateDecls,
- MutableArrayRef<mlir::Value> mlirPrivateVars,
- llvm::SmallVectorImpl<llvm::Value *> &llvmPrivateVars,
+ PrivateVarsInfo &privateVarsInfo,
const llvm::OpenMPIRBuilder::InsertPointTy &allocaIP,
llvm::DenseMap<Value, Value> *mappedPrivateVars = nullptr) {
// Allocate private vars
@@ -1458,7 +1474,8 @@ allocatePrivateVars(llvm::IRBuilderBase &builder,
.getProgramAddressSpace();
for (auto [privDecl, mlirPrivVar, blockArg] :
- llvm::zip_equal(privateDecls, mlirPrivateVars, privateBlockArgs)) {
+ llvm::zip_equal(privateVarsInfo.privatizers, privateVarsInfo.mlirVars,
+ privateVarsInfo.blockArgs)) {
llvm::Type *llvmAllocType =
moduleTranslation.convertType(privDecl.getType());
builder.SetInsertPoint(allocaIP.getBlock()->getTerminator());
@@ -1468,7 +1485,7 @@ allocatePrivateVars(llvm::IRBuilderBase &builder,
llvmPrivateVar = builder.CreateAddrSpaceCast(llvmPrivateVar,
builder.getPtrTy(defaultAS));
- llvmPrivateVars.push_back(llvmPrivateVar);
+ privateVarsInfo.llvmVars.push_back(llvmPrivateVar);
}
return afterAllocas;
@@ -1896,19 +1913,9 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
if (failed(checkImplementationStatus(*taskOp)))
return failure();
- // Collect delayed privatisation declarations
- MutableArrayRef<BlockArgument> privateBlockArgs =
- cast<omp::BlockArgOpenMPOpInterface>(*taskOp).getPrivateBlockArgs();
- SmallVector<mlir::Value> mlirPrivateVars;
- SmallVector<llvm::Value *> llvmPrivateVars;
- SmallVector<omp::PrivateClauseOp> privateDecls;
- mlirPrivateVars.reserve(privateBlockArgs.size());
- llvmPrivateVars.reserve(privateBlockArgs.size());
- collectPrivatizationDecls(taskOp, privateDecls);
+ PrivateVarsInfo privateVarsInfo(taskOp);
TaskContextStructManager taskStructMgr{builder, moduleTranslation,
- privateDecls};
- for (mlir::Value privateVar : taskOp.getPrivateVars())
- mlirPrivateVars.push_back(privateVar);
+ privateVarsInfo.privatizers};
// Allocate and copy private variables before creating the task. This avoids
// accessing invalid memory if (after this scope ends) the private variables
@@ -1967,7 +1974,8 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
taskStructMgr.createGEPsToPrivateVars();
for (auto [privDecl, mlirPrivVar, blockArg, llvmPrivateVarAlloc] :
- llvm::zip_equal(privateDecls, mlirPrivateVars, privateBlockArgs,
+ llvm::zip_equal(privateVarsInfo.privatizers, privateVarsInfo.mlirVars,
+ privateVarsInfo.blockArgs,
taskStructMgr.getLLVMPrivateVarGEPs())) {
// To be handled inside the task.
if (!privDecl.readsFromMold())
@@ -2006,9 +2014,9 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
// firstprivate copy region
setInsertPointForPossiblyEmptyBlock(builder, copyBlock);
- if (failed(copyFirstPrivateVars(builder, moduleTranslation, mlirPrivateVars,
- taskStructMgr.getLLVMPrivateVarGEPs(),
- privateDecls)))
+ if (failed(copyFirstPrivateVars(
+ builder, moduleTranslation, privateVarsInfo.mlirVars,
+ taskStructMgr.getLLVMPrivateVarGEPs(), privateVarsInfo.privatizers)))
return llvm::failure();
// Set up for call to createTask()
@@ -2025,9 +2033,10 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
builder.restoreIP(codegenIP);
llvm::BasicBlock *privInitBlock = nullptr;
- llvmPrivateVars.resize(privateBlockArgs.size());
+ privateVarsInfo.llvmVars.resize(privateVarsInfo.blockArgs.size());
for (auto [i, zip] : llvm::enumerate(llvm::zip_equal(
- privateBlockArgs, privateDecls, mlirPrivateVars))) {
+ privateVarsInfo.blockArgs, privateVarsInfo.privatizers,
+ privateVarsInfo.mlirVars))) {
auto [blockArg, privDecl, mlirPrivVar] = zip;
// This is handled before the task executes
if (privDecl.readsFromMold())
@@ -2046,23 +2055,25 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
if (!privateVarOrError)
return privateVarOrError.takeError();
moduleTranslation.mapValue(blockArg, privateVarOrError.get());
- llvmPrivateVars[i] = privateVarOrError.get();
+ privateVarsInfo.llvmVars[i] = privateVarOrError.get();
}
taskStructMgr.createGEPsToPrivateVars();
for (auto [i, llvmPrivVar] :
llvm::enumerate(taskStructMgr.getLLVMPrivateVarGEPs())) {
if (!llvmPrivVar) {
- assert(llvmPrivateVars[i] && "This is added in the loop above");
+ assert(privateVarsInfo.llvmVars[i] &&
+ "This is added in the loop above");
continue;
}
- llvmPrivateVars[i] = llvmPrivVar;
+ privateVarsInfo.llvmVars[i] = llvmPrivVar;
}
// Find and map the addresses of each variable within the task context
// structure
for (auto [blockArg, llvmPrivateVar, privateDecl] :
- llvm::zip_equal(privateBlockArgs, llvmPrivateVars, privateDecls)) {
+ llvm::zip_equal(privateVarsInfo.blockArgs, privateVarsInfo.llvmVars,
+ privateVarsInfo.privatizers)) {
// This was handled above.
if (!privateDecl.readsFromMold())
continue;
@@ -2084,7 +2095,8 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
builder.SetInsertPoint(continuationBlockOrError.get()->getTerminator());
if (failed(cleanupPrivateVars(builder, moduleTranslation, taskOp.getLoc(),
- llvmPrivateVars, privateDecls)))
+ privateVarsInfo.llvmVars,
+ privateVarsInfo.privatizers)))
return llvm::make_error<PreviouslyReportedError>();
// Free heap allocated task context structure at the end of the task.
@@ -2179,17 +2191,7 @@ convertOmpWsloop(Operation &opInst, llvm::IRBuilderBase &builder,
chunk = builder.CreateSExtOrTrunc(chunkVar, ivType);
}
- MutableArrayRef<BlockArgument> privateBlockArgs =
- cast<omp::BlockArgOpenMPOpInterface>(*wsloopOp).getPrivateBlockArgs();
- SmallVector<mlir::Value> mlirPrivateVars;
- SmallVector<llvm::Value *> llvmPrivateVars;
- SmallVector<omp::PrivateClauseOp> privateDecls;
- mlirPrivateVars.reserve(privateBlockArgs.size());
- llvmPrivateVars.reserve(privateBlockArgs.size());
- collectPrivatizationDecls(wsloopOp, privateDecls);
-
- for (mlir::Value privateVar : wsloopOp.getPrivateVars())
- mlirPrivateVars.push_back(privateVar);
+ PrivateVarsInfo privateVarsInfo(wsloopOp);
SmallVector<omp::DeclareReductionOp> reductionDecls;
collectReductionDecls(wsloopOp, reductionDecls);
@@ -2200,8 +2202,7 @@ convertOmpWsloop(Operation &opInst, llvm::IRBuilderBase &builder,
wsloopOp.getNumReductionVars());
llvm::Expected<llvm::BasicBlock *> afterAllocas = allocatePrivateVars(
- builder, moduleTranslation, privateBlockArgs, privateDecls,
- mlirPrivateVars, llvmPrivateVars, allocaIP);
+ builder, moduleTranslation, privateVarsInfo, allocaIP);
if (handleError(afterAllocas, opInst).failed())
return failure();
@@ -2218,15 +2219,14 @@ convertOmpWsloop(Operation &opInst, llvm::IRBuilderBase &builder,
deferredStores, isByRef)))
return failure();
- if (handleError(initPrivateVars(builder, moduleTranslation, privateBlockArgs,
- privateDecls, mlirPrivateVars,
- llvmPrivateVars),
+ if (handleError(initPrivateVars(builder, moduleTranslation, privateVarsInfo),
opInst)
.failed())
return failure();
- if (failed(copyFirstPrivateVars(builder, moduleTranslation, mlirPrivateVars,
- llvmPrivateVars, privateDecls)))
+ if (failed(copyFirstPrivateVars(
+ builder, moduleTranslation, privateVarsInfo.mlirVars,
+ privateVarsInfo.llvmVars, privateVarsInfo.privatizers)))
return failure();
assert(afterAllocas.get()->getSinglePredecessor());
@@ -2279,7 +2279,8 @@ convertOmpWsloop(Operation &opInst, llvm::IRBuilderBase &builder,
return failure();
return cleanupPrivateVars(builder, moduleTranslation, wsloopOp.getLoc(),
- llvmPrivateVars, privateDecls);
+ privateVarsInfo.llvmVars,
+ privateVarsInfo.privatizers);
}
/// Converts the OpenMP parallel operation to LLVM IR.
@@ -2294,17 +2295,7 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
if (failed(checkImplementationStatus(*opInst)))
return failure();
- // Collect delayed privatization declarations
- MutableArrayRef<BlockArgument> privateBlockArgs =
- cast<omp::BlockArgOpenMPOpInterface>(*opInst).getPrivateBlockArgs();
- SmallVector<mlir::Value> mlirPrivateVars;
- SmallVector<llvm::Value *> llvmPrivateVars;
- SmallVector<omp::PrivateClauseOp> privateDecls;
- mlirPrivateVars.reserve(privateBlockArgs.size());
- llvmPrivateVars.reserve(privateBlockArgs.size());
- collectPrivatizationDecls(opInst, privateDecls);
- for (mlir::Value privateVar : opInst.getPrivateVars())
- mlirPrivateVars.push_back(privateVar);
+ PrivateVarsInfo privateVarsInfo(opInst);
// Collect reduction declarations
SmallVector<omp::DeclareReductionOp> reductionDecls;
@@ -2316,8 +2307,7 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
auto bodyGenCB = [&](InsertPointTy allocaIP,
InsertPointTy codeGenIP) -> llvm::Error {
llvm::Expected<llvm::BasicBlock *> afterAllocas = allocatePrivateVars(
- builder, moduleTranslation, privateBlockArgs, privateDecls,
- mlirPrivateVars, llvmPrivateVars, allocaIP);
+ builder, moduleTranslation, privateVarsInfo, allocaIP);
if (handleError(afterAllocas, *opInst).failed())
return llvm::make_error<PreviouslyReportedError>();
@@ -2340,15 +2330,15 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
assert(afterAllocas.get()->getSinglePredecessor());
builder.restoreIP(codeGenIP);
- if (handleError(initPrivateVars(builder, moduleTranslation,
- privateBlockArgs, privateDecls,
- mlirPrivateVars, llvmPrivateVars),
- *opInst)
+ if (handleError(
+ initPrivateVars(builder, moduleTranslation, privateVarsInfo),
+ *opInst)
.failed())
return llvm::make_error<PreviouslyReportedError>();
- if (failed(copyFirstPrivateVars(builder, moduleTranslation, mlirPrivateVars,
- llvmPrivateVars, privateDecls)))
+ if (failed(copyFirstPrivateVars(
+ builder, moduleTranslation, privateVarsInfo.mlirVars,
+ privateVarsInfo.llvmVars, privateVarsInfo.privatizers)))
return llvm::make_error<PreviouslyReportedError>();
if (failed(
@@ -2430,7 +2420,8 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
"failed to inline `cleanup` region of `omp.declare_reduction`");
if (failed(cleanupPrivateVars(builder, moduleTranslation, opInst.getLoc(),
- llvmPrivateVars, privateDecls)))
+ privateVarsInfo.llvmVars,
+ privateVarsInfo.privatizers)))
return llvm::make_error<PreviouslyReportedError>();
builder.restoreIP(oldIP);
@@ -2498,30 +2489,17 @@ convertOmpSimd(Operation &opInst, llvm::IRBuilderBase &builder,
if (failed(checkImplementationStatus(opInst)))
return failure();
- MutableArrayRef<BlockArgument> privateBlockArgs =
- cast<omp::BlockArgOpenMPOpInterface>(*simdOp).getPrivateBlockArgs();
- SmallVector<mlir::Value> mlirPrivateVars;
- SmallVector<llvm::Value *> llvmPrivateVars;
- SmallVector<omp::PrivateClauseOp> privateDecls;
- mlirPrivateVars.reserve(privateBlockArgs.size());
- llvmPrivateVars.reserve(privateBlockArgs.size());
- collectPrivatizationDecls(simdOp, privateDecls);
-
- for (mlir::Value privateVar : simdOp.getPrivateVars())
- mlirPrivateVars.push_back(privateVar);
+ PrivateVarsInfo privateVarsInfo(simdOp);
llvm::OpenMPIRBuilder::InsertPointTy allocaIP =
findAllocaInsertPoint(builder, moduleTranslation);
llvm::Expected<llvm::BasicBlock *> afterAllocas = allocatePrivateVars(
- builder, moduleTranslation, privateBlockArgs, privateDecls,
- mlirPrivateVars, llvmPrivateVars, allocaIP);
+ builder, moduleTranslation, privateVarsInfo, allocaIP);
if (handleError(afterAllocas, opInst).failed())
return failure();
- if (handleError(initPrivateVars(builder, moduleTranslation, privateBlockArgs,
- privateDecls, mlirPrivateVars,
- llvmPrivateVars),
+ if (handleError(initPrivateVars(builder, moduleTranslation, privateVarsInfo),
opInst)
.failed())
return failure();
@@ -2570,7 +2548,8 @@ convertOmpSimd(Operation &opInst, llvm::IRBuilderBase &builder,
order, simdlen, safelen);
return cleanupPrivateVars(builder, moduleTranslation, simdOp.getLoc(),
- llvmPrivateVars, privateDecls);
+ privateVarsInfo.llvmVars,
+ privateVarsInfo.privatizers);
}
/// Converts an OpenMP loop nest into LLVM IR using OpenMPIRBuilder.
@@ -4194,37 +4173,21 @@ convertOmpDistribute(Operation &opInst, llvm::IRBuilderBase &builder,
// DistributeOp has only one region associated with it.
builder.restoreIP(codeGenIP);
+ PrivateVarsInfo privVarsInfo(distributeOp);
- // TODO This is a recurring pattern in almost all ops that need
- // privatization. Try to abstract it in a shared util/interface.
- MutableArrayRef<BlockArgument> privateBlockArgs =
- cast<omp::BlockArgOpenMPOpInterface>(*distributeOp)
- .getPrivateBlockArgs();
- SmallVector<mlir::Value> mlirPrivateVars;
- SmallVector<llvm::Value *> llvmPrivateVars;
- SmallVector<omp::PrivateClauseOp> privateDecls;
- mlirPrivateVars.reserve(privateBlockArgs.size());
- llvmPrivateVars.reserve(privateBlockArgs.size());
- collectPrivatizationDecls(distributeOp, privateDecls);
-
- for (mlir::Value privateVar : distributeOp.getPrivateVars())
- mlirPrivateVars.push_back(privateVar);
-
- llvm::Expected<llvm::BasicBlock *> afterAllocas = allocatePrivateVars(
- builder, moduleTranslation, privateBlockArgs, privateDecls,
- mlirPrivateVars, llvmPrivateVars, allocaIP);
+ llvm::Expected<llvm::BasicBlock *> afterAllocas =
+ allocatePrivateVars(builder, moduleTranslation, privVarsInfo, allocaIP);
if (handleError(afterAllocas, opInst).failed())
return llvm::make_error<PreviouslyReportedError>();
- if (handleError(initPrivateVars(builder, moduleTranslation,
- privateBlockArgs, privateDecls,
- mlirPrivateVars, llvmPrivateVars),
+ if (handleError(initPrivateVars(builder, moduleTranslation, privVarsInfo),
opInst)
.failed())
return llvm::make_error<PreviouslyReportedError>();
- if (failed(copyFirstPrivateVars(builder, moduleTranslation, mlirPrivateVars,
- llvmPrivateVars, privateDecls)))
+ if (failed(copyFirstPrivateVars(
+ builder, moduleTranslation, privVarsInfo.mlirVars,
+ privVarsInfo.llvmVars, privVarsInfo.privatizers)))
return llvm::make_error<PreviouslyReportedError>();
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
@@ -4266,8 +4229,8 @@ convertOmpDistribute(Operation &opInst, llvm::IRBuilderBase &builder,
}
if (failed(cleanupPrivateVars(builder, moduleTranslation,
- distributeOp.getLoc(), llvmPrivateVars,
- privateDecls)))
+ distributeOp.getLoc(), privVarsInfo.llvmVars,
+ privVarsInfo.privatizers)))
return llvm::make_error<PreviouslyReportedError>();
return llvm::Error::success();
@@ -4884,35 +4847,25 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
// Do privatization after moduleTranslation has already recorded
// mapped values.
- MutableArrayRef<BlockArgument> privateBlockArgs =
- argIface.getPrivateBlockArgs();
- SmallVector<mlir::Value> mlirPrivateVars;
- SmallVector<llvm::Value *> llvmPrivateVars;
- SmallVector<omp::PrivateClauseOp> privateDecls;
- mlirPrivateVars.reserve(privateBlockArgs.size());
- llvmPrivateVars.reserve(privateBlockArgs.size());
- collectPrivatizationDecls(targetOp, privateDecls);
- for (mlir::Value privateVar : targetOp.getPrivateVars())
- mlirPrivateVars.push_back(privateVar);
+ PrivateVarsInfo privateVarsInfo(targetOp);
- llvm::Expected<llvm::BasicBlock *> afterAllocas = allocatePrivateVars(
- builder, moduleTranslation, privateBlockArgs, privateDecls,
- mlirPrivateVars, llvmPrivateVars, allocaIP, &mappedPrivateVars);
+ llvm::Expected<llvm::BasicBlock *> afterAllocas =
+ allocatePrivateVars(builder, moduleTranslation, privateVarsInfo,
+ allocaIP, &mappedPrivateVars);
if (failed(handleError(afterAllocas, *targetOp)))
return llvm::make_error<PreviouslyReportedError>();
builder.restoreIP(codeGenIP);
- if (handleError(initPrivateVars(builder, moduleTranslation,
- privateBlockArgs, privateDecls,
- mlirPrivateVars, llvmPrivateVars,
+ if (handleError(initPrivateVars(builder, moduleTranslation, privateVarsInfo,
&mappedPrivateVars),
*targetOp)
.failed())
return llvm::make_error<PreviouslyReportedError>();
SmallVector<Region *> privateCleanupRegions;
- llvm::transform(privateDecls, std::back_inserter(privateCleanupRegions),
+ llvm::transform(privateVarsInfo.privatizers,
+ std::back_inserter(privateCleanupRegions),
[](omp::PrivateClauseOp privatizer) {
return &privatizer.getDeallocRegion();
});
@@ -4926,8 +4879,8 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
builder.SetInsertPoint(*exitBlock);
if (!privateCleanupRegions.empty()) {
if (failed(inlineOmpRegionCleanup(
- privateCleanupRegions, llvmPrivateVars, moduleTranslation,
- builder, "omp.targetop.private.cleanup",
+ privateCleanupRegions, privateVarsInfo.llvmVars,
+ moduleTranslation, builder, "omp.targetop.private.cleanup",
/*shouldLoadCleanupRegionArg=*/false))) {
return llvm::createStringError(
"failed to inline `dealloc` region of `omp.private` "
More information about the Mlir-commits
mailing list