@@ -770,7 +770,7 @@ static void allocByValReductionVars(
770
770
DenseMap<Value, llvm::Value *> &reductionVariableMap,
771
771
llvm::ArrayRef<bool > isByRefs) {
772
772
llvm::IRBuilderBase::InsertPointGuard guard (builder);
773
- builder.restoreIP (allocaIP);
773
+ builder.SetInsertPoint (allocaIP. getBlock ()-> getTerminator () );
774
774
auto args =
775
775
loop.getRegion ().getArguments ().take_back (loop.getNumReductionVars ());
776
776
@@ -1155,7 +1155,10 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
1155
1155
opInst.getRegion ().getArguments ().take_back (
1156
1156
opInst.getNumReductionVars ());
1157
1157
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 ());
1159
1162
SmallVector<llvm::Value *> byRefVars;
1160
1163
if (isByRef) {
1161
1164
for (unsigned i = 0 ; i < opInst.getNumReductionVars (); ++i) {
@@ -1165,8 +1168,6 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
1165
1168
moduleTranslation.convertType (reductionDecls[i].getType ())));
1166
1169
}
1167
1170
1168
- initBlock = splitBB (builder, true , " omp.reduction.init" );
1169
- allocaIP = InsertPointTy (allocaIP.getBlock (), allocaIP.getBlock ()->end ());
1170
1171
}
1171
1172
1172
1173
for (unsigned i = 0 ; i < opInst.getNumReductionVars (); ++i) {
@@ -1181,10 +1182,8 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
1181
1182
assert (phis.size () == 1 &&
1182
1183
" expected one value to be yielded from the "
1183
1184
" 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
+
1188
1187
if (isByRef) {
1189
1188
// Store the result of the inlined region to the allocated reduction var
1190
1189
// ptr
0 commit comments