Skip to content

Commit 5009eb4

Browse files
authored
Push down declarations and remove wrapper functions. (llvm#206)
1 parent 62fa744 commit 5009eb4

File tree

1 file changed

+14
-37
lines changed

1 file changed

+14
-37
lines changed

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,14 +1294,15 @@ static LogicalResult createReductionsAndCleanup(
12941294
llvm::OpenMPIRBuilder::InsertPointTy &allocaIP,
12951295
SmallVectorImpl<omp::DeclareReductionOp> &reductionDecls,
12961296
ArrayRef<llvm::Value *> privateReductionVariables, ArrayRef<bool> isByRef,
1297-
SmallVector<OwningReductionGen> &owningReductionGens,
1298-
SmallVector<OwningAtomicReductionGen> &owningAtomicReductionGens,
1299-
SmallVector<llvm::OpenMPIRBuilder::ReductionInfo> &reductionInfos,
13001297
bool isNowait = false, bool isTeamsReduction = false) {
13011298
// Process the reductions if required.
13021299
if (op.getNumReductionVars() == 0)
13031300
return success();
13041301

1302+
SmallVector<OwningReductionGen> owningReductionGens;
1303+
SmallVector<OwningAtomicReductionGen> owningAtomicReductionGens;
1304+
SmallVector<llvm::OpenMPIRBuilder::ReductionInfo> reductionInfos;
1305+
13051306
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
13061307

13071308
// Create the reduction generators. We need to own them here because
@@ -1605,13 +1606,9 @@ convertOmpSections(Operation &opInst, llvm::IRBuilderBase &builder,
16051606
builder.restoreIP(*afterIP);
16061607

16071608
// Process the reductions if required.
1608-
SmallVector<OwningReductionGen> owningReductionGens;
1609-
SmallVector<OwningAtomicReductionGen> owningAtomicReductionGens;
1610-
SmallVector<llvm::OpenMPIRBuilder::ReductionInfo> reductionInfos;
16111609
return createReductionsAndCleanup(
16121610
sectionsOp, builder, moduleTranslation, allocaIP, reductionDecls,
1613-
privateReductionVariables, isByRef, owningReductionGens,
1614-
owningAtomicReductionGens, reductionInfos, sectionsOp.getNowait());
1611+
privateReductionVariables, isByRef, sectionsOp.getNowait());
16151612
}
16161613

16171614
/// Converts an OpenMP single construct into LLVM IR using OpenMPIRBuilder.
@@ -1728,15 +1725,11 @@ convertOmpTeams(omp::TeamsOp op, llvm::IRBuilderBase &builder,
17281725
builder.restoreIP(*afterIP);
17291726

17301727
// Process the reductions if required.
1731-
SmallVector<OwningReductionGen> owningReductionGens;
1732-
SmallVector<OwningAtomicReductionGen> owningAtomicReductionGens;
1733-
SmallVector<llvm::OpenMPIRBuilder::ReductionInfo> reductionInfos;
17341728
return createReductionsAndCleanup(
17351729
op, builder, moduleTranslation, allocaIP, reductionDecls,
1736-
privateReductionVariables, isByRef, owningReductionGens,
1737-
owningAtomicReductionGens, reductionInfos,
1730+
privateReductionVariables, isByRef,
17381731
/*isNoWait*/ false, /*isTeamsReduction*/ true);
1739-
1732+
17401733
return success();
17411734
}
17421735

@@ -1931,13 +1924,12 @@ convertOmpTaskwaitOp(omp::TaskwaitOp twOp, llvm::IRBuilderBase &builder,
19311924
}
19321925

19331926
/// Converts an OpenMP workshare loop into LLVM IR using OpenMPIRBuilder.
1934-
static LogicalResult convertOmpWsloop(
1935-
Operation &opInst, llvm::IRBuilderBase &builder,
1936-
LLVM::ModuleTranslation &moduleTranslation,
1937-
llvm::OpenMPIRBuilder::InsertPointTy redAllocaIP,
1938-
SmallVector<OwningReductionGen> &owningReductionGens,
1939-
SmallVector<OwningAtomicReductionGen> &owningAtomicReductionGens,
1940-
SmallVector<llvm::OpenMPIRBuilder::ReductionInfo> &reductionInfos) {
1927+
static LogicalResult
1928+
convertOmpWsloop(Operation &opInst, llvm::IRBuilderBase &builder,
1929+
LLVM::ModuleTranslation &moduleTranslation) {
1930+
llvm::OpenMPIRBuilder::InsertPointTy redAllocaIP =
1931+
findAllocaInsertPoint(builder, moduleTranslation);
1932+
19411933
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
19421934
// FIXME: This ignores any other nested wrappers (e.g. omp.simd).
19431935
auto wsloopOp = cast<omp::WsloopOp>(opInst);
@@ -2114,25 +2106,10 @@ static LogicalResult convertOmpWsloop(
21142106
// Process the reductions if required.
21152107
return createReductionsAndCleanup(
21162108
wsloopOp, builder, moduleTranslation, allocaIP, reductionDecls,
2117-
privateReductionVariables, isByRef, owningReductionGens,
2118-
owningAtomicReductionGens, reductionInfos, wsloopOp.getNowait(),
2109+
privateReductionVariables, isByRef, wsloopOp.getNowait(),
21192110
/*isTeamsReduction=*/false);
21202111
}
21212112

2122-
static LogicalResult
2123-
convertOmpWsloop(Operation &opInst, llvm::IRBuilderBase &builder,
2124-
LLVM::ModuleTranslation &moduleTranslation) {
2125-
llvm::OpenMPIRBuilder::InsertPointTy redAllocaIP =
2126-
findAllocaInsertPoint(builder, moduleTranslation);
2127-
SmallVector<OwningReductionGen> owningReductionGens;
2128-
SmallVector<OwningAtomicReductionGen> owningAtomicReductionGens;
2129-
SmallVector<llvm::OpenMPIRBuilder::ReductionInfo> reductionInfos;
2130-
2131-
return convertOmpWsloop(opInst, builder, moduleTranslation, redAllocaIP,
2132-
owningReductionGens, owningAtomicReductionGens,
2133-
reductionInfos);
2134-
}
2135-
21362113
/// Converts the OpenMP parallel operation to LLVM IR.
21372114
static LogicalResult
21382115
convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,

0 commit comments

Comments
 (0)