Skip to content

Commit 0237b82

Browse files
committed
Address intermittent ICE triggered from the OpenMPIRBuilder::finalize method due to an invalid builder insertion point
1 parent 8b34402 commit 0237b82

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
@@ -5834,6 +5834,7 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
58345834

58355835
static LogicalResult
58365836
convertDeclareTargetAttr(Operation *op, mlir::omp::DeclareTargetAttr attribute,
5837+
llvm::OpenMPIRBuilder *ompBuilder,
58375838
LLVM::ModuleTranslation &moduleTranslation) {
58385839
// Amend omp.declare_target by deleting the IR of the outlined functions
58395840
// created for target regions. They cannot be filtered out from MLIR earlier
@@ -5856,6 +5857,11 @@ convertDeclareTargetAttr(Operation *op, mlir::omp::DeclareTargetAttr attribute,
58565857
moduleTranslation.lookupFunction(funcOp.getName());
58575858
llvmFunc->dropAllReferences();
58585859
llvmFunc->eraseFromParent();
5860+
5861+
// Invalidate the builder's current insertion point, as it now points to
5862+
// a deleted block.
5863+
ompBuilder->Builder.ClearInsertionPoint();
5864+
ompBuilder->Builder.SetCurrentDebugLocation(llvm::DebugLoc());
58595865
}
58605866
}
58615867
return success();
@@ -6300,9 +6306,12 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::amendOperation(
63006306
.Case("omp.declare_target",
63016307
[&](Attribute attr) {
63026308
if (auto declareTargetAttr =
6303-
dyn_cast<omp::DeclareTargetAttr>(attr))
6309+
dyn_cast<omp::DeclareTargetAttr>(attr)) {
6310+
llvm::OpenMPIRBuilder *ompBuilder =
6311+
moduleTranslation.getOpenMPBuilder();
63046312
return convertDeclareTargetAttr(op, declareTargetAttr,
6305-
moduleTranslation);
6313+
ompBuilder, moduleTranslation);
6314+
}
63066315
return failure();
63076316
})
63086317
.Case("omp.requires",

0 commit comments

Comments
 (0)