Skip to content

Commit 8bd7596

Browse files
Review fixes
1 parent 5cd1a43 commit 8bd7596

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,7 +2159,7 @@ OpenMPIRBuilder::createReductions(const LocationDescription &Loc,
21592159
Builder.SetInsertPoint(AllocaIP.getBlock()->getTerminator());
21602160
Value *RedArray = Builder.CreateAlloca(RedArrayTy, nullptr, "red.array");
21612161

2162-
Builder.SetInsertPoint(InsertBlock, InsertBlock->begin());
2162+
Builder.SetInsertPoint(InsertBlock, InsertBlock->end());
21632163

21642164
for (auto En : enumerate(ReductionInfos)) {
21652165
unsigned Index = En.index();
@@ -3120,7 +3120,7 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::applyDynamicWorkshareLoop(
31203120
FunctionCallee DynamicNext = getKmpcForDynamicNextForType(IVTy, M, *this);
31213121

31223122
// Allocate space for computed loop bounds as expected by the "init" function.
3123-
Builder.restoreIP(AllocaIP);
3123+
Builder.SetInsertPoint(AllocaIP.getBlock()->getTerminator());
31243124
Type *I32Type = Type::getInt32Ty(M.getContext());
31253125
Value *PLastIter = Builder.CreateAlloca(I32Type, nullptr, "p.lastiter");
31263126
Value *PLowerBound = Builder.CreateAlloca(IVTy, nullptr, "p.lowerbound");

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ static void allocByValReductionVars(
770770
DenseMap<Value, llvm::Value *> &reductionVariableMap,
771771
llvm::ArrayRef<bool> isByRefs) {
772772
llvm::IRBuilderBase::InsertPointGuard guard(builder);
773-
builder.restoreIP(allocaIP);
773+
builder.SetInsertPoint(allocaIP.getBlock()->getTerminator());
774774
auto args =
775775
loop.getRegion().getArguments().take_back(loop.getNumReductionVars());
776776

@@ -1155,7 +1155,10 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
11551155
opInst.getRegion().getArguments().take_back(
11561156
opInst.getNumReductionVars());
11571157

1158-
llvm::BasicBlock *initBlock = nullptr;
1158+
llvm::BasicBlock *initBlock = splitBB(builder, true, "omp.reduction.init");
1159+
allocaIP =
1160+
InsertPointTy(allocaIP.getBlock(),
1161+
allocaIP.getBlock()->getTerminator()->getIterator());
11591162
SmallVector<llvm::Value *> byRefVars;
11601163
if (isByRef) {
11611164
for (unsigned i = 0; i < opInst.getNumReductionVars(); ++i) {
@@ -1165,8 +1168,6 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
11651168
moduleTranslation.convertType(reductionDecls[i].getType())));
11661169
}
11671170

1168-
initBlock = splitBB(builder, true, "omp.reduction.init");
1169-
allocaIP = InsertPointTy(allocaIP.getBlock(), allocaIP.getBlock()->end());
11701171
}
11711172

11721173
for (unsigned i = 0; i < opInst.getNumReductionVars(); ++i) {
@@ -1181,10 +1182,8 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
11811182
assert(phis.size() == 1 &&
11821183
"expected one value to be yielded from the "
11831184
"reduction neutral element declaration region");
1184-
if (initBlock)
1185-
builder.SetInsertPoint(initBlock->getTerminator());
1186-
else
1187-
builder.restoreIP(allocaIP);
1185+
builder.SetInsertPoint(initBlock->getTerminator());
1186+
11881187
if (isByRef) {
11891188
// Store the result of the inlined region to the allocated reduction var
11901189
// ptr

0 commit comments

Comments
 (0)