@@ -701,34 +701,33 @@ convertOmpCritical(Operation &opInst, llvm::IRBuilderBase &builder,
701
701
struct PrivateVarsInfo {
702
702
template <typename OP>
703
703
PrivateVarsInfo (OP op)
704
- : privateBlockArgs (
704
+ : blockArgs (
705
705
cast<omp::BlockArgOpenMPOpInterface>(*op).getPrivateBlockArgs()) {
706
- mlirPrivateVars .reserve (privateBlockArgs .size ());
707
- llvmPrivateVars .reserve (privateBlockArgs .size ());
708
- collectPrivatizationDecls<OP>(op, privateDecls );
706
+ mlirVars .reserve (blockArgs .size ());
707
+ llvmVars .reserve (blockArgs .size ());
708
+ collectPrivatizationDecls<OP>(op);
709
709
710
710
for (mlir::Value privateVar : op.getPrivateVars ())
711
- mlirPrivateVars .push_back (privateVar);
711
+ mlirVars .push_back (privateVar);
712
712
}
713
713
714
- MutableArrayRef<BlockArgument> privateBlockArgs ;
715
- SmallVector<mlir::Value> mlirPrivateVars ;
716
- SmallVector<llvm::Value *> llvmPrivateVars ;
717
- SmallVector<omp::PrivateClauseOp> privateDecls ;
714
+ MutableArrayRef<BlockArgument> blockArgs ;
715
+ SmallVector<mlir::Value> mlirVars ;
716
+ SmallVector<llvm::Value *> llvmVars ;
717
+ SmallVector<omp::PrivateClauseOp> privatizers ;
718
718
719
719
private:
720
720
// / Populates `privatizations` with privatization declarations used for the
721
721
// / given op.
722
722
template <class OP >
723
- static void collectPrivatizationDecls (
724
- OP op, SmallVectorImpl<omp::PrivateClauseOp> &privatizations) {
723
+ void collectPrivatizationDecls (OP op) {
725
724
std::optional<ArrayAttr> attr = op.getPrivateSyms ();
726
725
if (!attr)
727
726
return ;
728
727
729
- privatizations .reserve (privatizations .size () + attr->size ());
728
+ privatizers .reserve (privatizers .size () + attr->size ());
730
729
for (auto symbolRef : attr->getAsRange <SymbolRefAttr>()) {
731
- privatizations .push_back (findPrivatizer (op, symbolRef));
730
+ privatizers .push_back (findPrivatizer (op, symbolRef));
732
731
}
733
732
}
734
733
};
@@ -1408,16 +1407,15 @@ initPrivateVars(llvm::IRBuilderBase &builder,
1408
1407
LLVM::ModuleTranslation &moduleTranslation,
1409
1408
PrivateVarsInfo &privateVarsInfo,
1410
1409
llvm::DenseMap<Value, Value> *mappedPrivateVars = nullptr ) {
1411
- if (privateVarsInfo.privateBlockArgs .empty ())
1410
+ if (privateVarsInfo.blockArgs .empty ())
1412
1411
return llvm::Error::success ();
1413
1412
1414
1413
llvm::BasicBlock *privInitBlock = splitBB (builder, true , " omp.private.init" );
1415
1414
setInsertPointForPossiblyEmptyBlock (builder, privInitBlock);
1416
1415
1417
1416
for (auto [idx, zip] : llvm::enumerate (llvm::zip_equal (
1418
- privateVarsInfo.privateDecls , privateVarsInfo.mlirPrivateVars ,
1419
- privateVarsInfo.privateBlockArgs ,
1420
- privateVarsInfo.llvmPrivateVars ))) {
1417
+ privateVarsInfo.privatizers , privateVarsInfo.mlirVars ,
1418
+ privateVarsInfo.blockArgs , privateVarsInfo.llvmVars ))) {
1421
1419
auto [privDecl, mlirPrivVar, blockArg, llvmPrivateVar] = zip;
1422
1420
llvm::Expected<llvm::Value *> privVarOrErr = initPrivateVar (
1423
1421
builder, moduleTranslation, privDecl, mlirPrivVar, blockArg,
@@ -1467,9 +1465,9 @@ allocatePrivateVars(llvm::IRBuilderBase &builder,
1467
1465
->getDataLayout ()
1468
1466
.getProgramAddressSpace ();
1469
1467
1470
- for (auto [privDecl, mlirPrivVar, blockArg] : llvm::zip_equal (
1471
- privateVarsInfo.privateDecls , privateVarsInfo.mlirPrivateVars ,
1472
- privateVarsInfo.privateBlockArgs )) {
1468
+ for (auto [privDecl, mlirPrivVar, blockArg] :
1469
+ llvm::zip_equal ( privateVarsInfo.privatizers , privateVarsInfo.mlirVars ,
1470
+ privateVarsInfo.blockArgs )) {
1473
1471
llvm::Type *llvmAllocType =
1474
1472
moduleTranslation.convertType (privDecl.getType ());
1475
1473
builder.SetInsertPoint (allocaIP.getBlock ()->getTerminator ());
@@ -1479,7 +1477,7 @@ allocatePrivateVars(llvm::IRBuilderBase &builder,
1479
1477
llvmPrivateVar = builder.CreateAddrSpaceCast (llvmPrivateVar,
1480
1478
builder.getPtrTy (defaultAS));
1481
1479
1482
- privateVarsInfo.llvmPrivateVars .push_back (llvmPrivateVar);
1480
+ privateVarsInfo.llvmVars .push_back (llvmPrivateVar);
1483
1481
}
1484
1482
1485
1483
return afterAllocas;
@@ -1909,7 +1907,7 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
1909
1907
1910
1908
PrivateVarsInfo privateVarsInfo (taskOp);
1911
1909
TaskContextStructManager taskStructMgr{builder, moduleTranslation,
1912
- privateVarsInfo.privateDecls };
1910
+ privateVarsInfo.privatizers };
1913
1911
1914
1912
// Allocate and copy private variables before creating the task. This avoids
1915
1913
// accessing invalid memory if (after this scope ends) the private variables
@@ -1968,9 +1966,8 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
1968
1966
taskStructMgr.createGEPsToPrivateVars ();
1969
1967
1970
1968
for (auto [privDecl, mlirPrivVar, blockArg, llvmPrivateVarAlloc] :
1971
- llvm::zip_equal (privateVarsInfo.privateDecls ,
1972
- privateVarsInfo.mlirPrivateVars ,
1973
- privateVarsInfo.privateBlockArgs ,
1969
+ llvm::zip_equal (privateVarsInfo.privatizers , privateVarsInfo.mlirVars ,
1970
+ privateVarsInfo.blockArgs ,
1974
1971
taskStructMgr.getLLVMPrivateVarGEPs ())) {
1975
1972
// To be handled inside the task.
1976
1973
if (!privDecl.readsFromMold ())
@@ -2010,8 +2007,8 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
2010
2007
// firstprivate copy region
2011
2008
setInsertPointForPossiblyEmptyBlock (builder, copyBlock);
2012
2009
if (failed (copyFirstPrivateVars (
2013
- builder, moduleTranslation, privateVarsInfo.mlirPrivateVars ,
2014
- taskStructMgr.getLLVMPrivateVarGEPs (), privateVarsInfo.privateDecls )))
2010
+ builder, moduleTranslation, privateVarsInfo.mlirVars ,
2011
+ taskStructMgr.getLLVMPrivateVarGEPs (), privateVarsInfo.privatizers )))
2015
2012
return llvm::failure ();
2016
2013
2017
2014
// Set up for call to createTask()
@@ -2028,11 +2025,10 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
2028
2025
builder.restoreIP (codegenIP);
2029
2026
2030
2027
llvm::BasicBlock *privInitBlock = nullptr ;
2031
- privateVarsInfo.llvmPrivateVars .resize (
2032
- privateVarsInfo.privateBlockArgs .size ());
2028
+ privateVarsInfo.llvmVars .resize (privateVarsInfo.blockArgs .size ());
2033
2029
for (auto [i, zip] : llvm::enumerate (llvm::zip_equal (
2034
- privateVarsInfo.privateBlockArgs , privateVarsInfo.privateDecls ,
2035
- privateVarsInfo.mlirPrivateVars ))) {
2030
+ privateVarsInfo.blockArgs , privateVarsInfo.privatizers ,
2031
+ privateVarsInfo.mlirVars ))) {
2036
2032
auto [blockArg, privDecl, mlirPrivVar] = zip;
2037
2033
// This is handled before the task executes
2038
2034
if (privDecl.readsFromMold ())
@@ -2051,25 +2047,25 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
2051
2047
if (!privateVarOrError)
2052
2048
return privateVarOrError.takeError ();
2053
2049
moduleTranslation.mapValue (blockArg, privateVarOrError.get ());
2054
- privateVarsInfo.llvmPrivateVars [i] = privateVarOrError.get ();
2050
+ privateVarsInfo.llvmVars [i] = privateVarOrError.get ();
2055
2051
}
2056
2052
2057
2053
taskStructMgr.createGEPsToPrivateVars ();
2058
2054
for (auto [i, llvmPrivVar] :
2059
2055
llvm::enumerate (taskStructMgr.getLLVMPrivateVarGEPs ())) {
2060
2056
if (!llvmPrivVar) {
2061
- assert (privateVarsInfo.llvmPrivateVars [i] &&
2057
+ assert (privateVarsInfo.llvmVars [i] &&
2062
2058
" This is added in the loop above" );
2063
2059
continue ;
2064
2060
}
2065
- privateVarsInfo.llvmPrivateVars [i] = llvmPrivVar;
2061
+ privateVarsInfo.llvmVars [i] = llvmPrivVar;
2066
2062
}
2067
2063
2068
2064
// Find and map the addresses of each variable within the task context
2069
2065
// structure
2070
- for (auto [blockArg, llvmPrivateVar, privateDecl] : llvm::zip_equal (
2071
- privateVarsInfo.privateBlockArgs , privateVarsInfo.llvmPrivateVars ,
2072
- privateVarsInfo.privateDecls )) {
2066
+ for (auto [blockArg, llvmPrivateVar, privateDecl] :
2067
+ llvm::zip_equal ( privateVarsInfo.blockArgs , privateVarsInfo.llvmVars ,
2068
+ privateVarsInfo.privatizers )) {
2073
2069
// This was handled above.
2074
2070
if (!privateDecl.readsFromMold ())
2075
2071
continue ;
@@ -2091,8 +2087,8 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
2091
2087
builder.SetInsertPoint (continuationBlockOrError.get ()->getTerminator ());
2092
2088
2093
2089
if (failed (cleanupPrivateVars (builder, moduleTranslation, taskOp.getLoc (),
2094
- privateVarsInfo.llvmPrivateVars ,
2095
- privateVarsInfo.privateDecls )))
2090
+ privateVarsInfo.llvmVars ,
2091
+ privateVarsInfo.privatizers )))
2096
2092
return llvm::make_error<PreviouslyReportedError>();
2097
2093
2098
2094
// Free heap allocated task context structure at the end of the task.
@@ -2221,8 +2217,8 @@ convertOmpWsloop(Operation &opInst, llvm::IRBuilderBase &builder,
2221
2217
return failure ();
2222
2218
2223
2219
if (failed (copyFirstPrivateVars (
2224
- builder, moduleTranslation, privateVarsInfo.mlirPrivateVars ,
2225
- privateVarsInfo.llvmPrivateVars , privateVarsInfo.privateDecls )))
2220
+ builder, moduleTranslation, privateVarsInfo.mlirVars ,
2221
+ privateVarsInfo.llvmVars , privateVarsInfo.privatizers )))
2226
2222
return failure ();
2227
2223
2228
2224
assert (afterAllocas.get ()->getSinglePredecessor ());
@@ -2275,8 +2271,8 @@ convertOmpWsloop(Operation &opInst, llvm::IRBuilderBase &builder,
2275
2271
return failure ();
2276
2272
2277
2273
return cleanupPrivateVars (builder, moduleTranslation, wsloopOp.getLoc (),
2278
- privateVarsInfo.llvmPrivateVars ,
2279
- privateVarsInfo.privateDecls );
2274
+ privateVarsInfo.llvmVars ,
2275
+ privateVarsInfo.privatizers );
2280
2276
}
2281
2277
2282
2278
// / Converts the OpenMP parallel operation to LLVM IR.
@@ -2333,8 +2329,8 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
2333
2329
return llvm::make_error<PreviouslyReportedError>();
2334
2330
2335
2331
if (failed (copyFirstPrivateVars (
2336
- builder, moduleTranslation, privateVarsInfo.mlirPrivateVars ,
2337
- privateVarsInfo.llvmPrivateVars , privateVarsInfo.privateDecls )))
2332
+ builder, moduleTranslation, privateVarsInfo.mlirVars ,
2333
+ privateVarsInfo.llvmVars , privateVarsInfo.privatizers )))
2338
2334
return llvm::make_error<PreviouslyReportedError>();
2339
2335
2340
2336
if (failed (
@@ -2416,8 +2412,8 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
2416
2412
" failed to inline `cleanup` region of `omp.declare_reduction`" );
2417
2413
2418
2414
if (failed (cleanupPrivateVars (builder, moduleTranslation, opInst.getLoc (),
2419
- privateVarsInfo.llvmPrivateVars ,
2420
- privateVarsInfo.privateDecls )))
2415
+ privateVarsInfo.llvmVars ,
2416
+ privateVarsInfo.privatizers )))
2421
2417
return llvm::make_error<PreviouslyReportedError>();
2422
2418
2423
2419
builder.restoreIP (oldIP);
@@ -2544,8 +2540,8 @@ convertOmpSimd(Operation &opInst, llvm::IRBuilderBase &builder,
2544
2540
order, simdlen, safelen);
2545
2541
2546
2542
return cleanupPrivateVars (builder, moduleTranslation, simdOp.getLoc (),
2547
- privateVarsInfo.llvmPrivateVars ,
2548
- privateVarsInfo.privateDecls );
2543
+ privateVarsInfo.llvmVars ,
2544
+ privateVarsInfo.privatizers );
2549
2545
}
2550
2546
2551
2547
// / Converts an OpenMP loop nest into LLVM IR using OpenMPIRBuilder.
@@ -4182,8 +4178,8 @@ convertOmpDistribute(Operation &opInst, llvm::IRBuilderBase &builder,
4182
4178
return llvm::make_error<PreviouslyReportedError>();
4183
4179
4184
4180
if (failed (copyFirstPrivateVars (
4185
- builder, moduleTranslation, privVarsInfo.mlirPrivateVars ,
4186
- privVarsInfo.llvmPrivateVars , privVarsInfo.privateDecls )))
4181
+ builder, moduleTranslation, privVarsInfo.mlirVars ,
4182
+ privVarsInfo.llvmVars , privVarsInfo.privatizers )))
4187
4183
return llvm::make_error<PreviouslyReportedError>();
4188
4184
4189
4185
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder ();
@@ -4224,9 +4220,9 @@ convertOmpDistribute(Operation &opInst, llvm::IRBuilderBase &builder,
4224
4220
return wsloopIP.takeError ();
4225
4221
}
4226
4222
4227
- if (failed (cleanupPrivateVars (
4228
- builder, moduleTranslation, distributeOp.getLoc (),
4229
- privVarsInfo. llvmPrivateVars , privVarsInfo.privateDecls )))
4223
+ if (failed (cleanupPrivateVars (builder, moduleTranslation,
4224
+ distributeOp.getLoc (), privVarsInfo. llvmVars ,
4225
+ privVarsInfo.privatizers )))
4230
4226
return llvm::make_error<PreviouslyReportedError>();
4231
4227
4232
4228
return llvm::Error::success ();
@@ -4860,7 +4856,7 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
4860
4856
return llvm::make_error<PreviouslyReportedError>();
4861
4857
4862
4858
SmallVector<Region *> privateCleanupRegions;
4863
- llvm::transform (privateVarsInfo.privateDecls ,
4859
+ llvm::transform (privateVarsInfo.privatizers ,
4864
4860
std::back_inserter (privateCleanupRegions),
4865
4861
[](omp::PrivateClauseOp privatizer) {
4866
4862
return &privatizer.getDeallocRegion ();
@@ -4875,7 +4871,7 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
4875
4871
builder.SetInsertPoint (*exitBlock);
4876
4872
if (!privateCleanupRegions.empty ()) {
4877
4873
if (failed (inlineOmpRegionCleanup (
4878
- privateCleanupRegions, privateVarsInfo.llvmPrivateVars ,
4874
+ privateCleanupRegions, privateVarsInfo.llvmVars ,
4879
4875
moduleTranslation, builder, " omp.targetop.private.cleanup" ,
4880
4876
/* shouldLoadCleanupRegionArg=*/ false ))) {
4881
4877
return llvm::createStringError (
0 commit comments