Skip to content

Commit 4da11cf

Browse files
committed
Address intermittent ICE triggered from the OpenMPIRBuilder::finalize method due to an invalid builder insertion point
1 parent 688b614 commit 4da11cf

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5872,6 +5872,7 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
58725872

58735873
static LogicalResult
58745874
convertDeclareTargetAttr(Operation *op, mlir::omp::DeclareTargetAttr attribute,
5875+
llvm::OpenMPIRBuilder *ompBuilder,
58755876
LLVM::ModuleTranslation &moduleTranslation) {
58765877
// Amend omp.declare_target by deleting the IR of the outlined functions
58775878
// created for target regions. They cannot be filtered out from MLIR earlier
@@ -5894,6 +5895,11 @@ convertDeclareTargetAttr(Operation *op, mlir::omp::DeclareTargetAttr attribute,
58945895
moduleTranslation.lookupFunction(funcOp.getName());
58955896
llvmFunc->dropAllReferences();
58965897
llvmFunc->eraseFromParent();
5898+
5899+
// Invalidate the builder's current insertion point, as it now points to
5900+
// a deleted block.
5901+
ompBuilder->Builder.ClearInsertionPoint();
5902+
ompBuilder->Builder.SetCurrentDebugLocation(llvm::DebugLoc());
58975903
}
58985904
}
58995905
return success();
@@ -6338,9 +6344,12 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::amendOperation(
63386344
.Case("omp.declare_target",
63396345
[&](Attribute attr) {
63406346
if (auto declareTargetAttr =
6341-
dyn_cast<omp::DeclareTargetAttr>(attr))
6347+
dyn_cast<omp::DeclareTargetAttr>(attr)) {
6348+
llvm::OpenMPIRBuilder *ompBuilder =
6349+
moduleTranslation.getOpenMPBuilder();
63426350
return convertDeclareTargetAttr(op, declareTargetAttr,
6343-
moduleTranslation);
6351+
ompBuilder, moduleTranslation);
6352+
}
63446353
return failure();
63456354
})
63466355
.Case("omp.requires",

0 commit comments

Comments
 (0)