Skip to content

Commit b9238c5

Browse files
committed
Address intermittent ICE triggered from the OpenMPIRBuilder::finalize method due to an invalid builder insertion point
1 parent fa55e45 commit b9238c5

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

59545954
static LogicalResult
59555955
convertDeclareTargetAttr(Operation *op, mlir::omp::DeclareTargetAttr attribute,
5956+
llvm::OpenMPIRBuilder *ompBuilder,
59565957
LLVM::ModuleTranslation &moduleTranslation) {
59575958
// Amend omp.declare_target by deleting the IR of the outlined functions
59585959
// created for target regions. They cannot be filtered out from MLIR earlier
@@ -5975,6 +5976,11 @@ convertDeclareTargetAttr(Operation *op, mlir::omp::DeclareTargetAttr attribute,
59755976
moduleTranslation.lookupFunction(funcOp.getName());
59765977
llvmFunc->dropAllReferences();
59775978
llvmFunc->eraseFromParent();
5979+
5980+
// Invalidate the builder's current insertion point, as it now points to
5981+
// a deleted block.
5982+
ompBuilder->Builder.ClearInsertionPoint();
5983+
ompBuilder->Builder.SetCurrentDebugLocation(llvm::DebugLoc());
59785984
}
59795985
}
59805986
return success();
@@ -6512,9 +6518,12 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::amendOperation(
65126518
.Case("omp.declare_target",
65136519
[&](Attribute attr) {
65146520
if (auto declareTargetAttr =
6515-
dyn_cast<omp::DeclareTargetAttr>(attr))
6521+
dyn_cast<omp::DeclareTargetAttr>(attr)) {
6522+
llvm::OpenMPIRBuilder *ompBuilder =
6523+
moduleTranslation.getOpenMPBuilder();
65166524
return convertDeclareTargetAttr(op, declareTargetAttr,
6517-
moduleTranslation);
6525+
ompBuilder, moduleTranslation);
6526+
}
65186527
return failure();
65196528
})
65206529
.Case("omp.requires",

0 commit comments

Comments
 (0)