@@ -5834,6 +5834,7 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
5834
5834
5835
5835
static LogicalResult
5836
5836
convertDeclareTargetAttr (Operation *op, mlir::omp::DeclareTargetAttr attribute,
5837
+ llvm::OpenMPIRBuilder *ompBuilder,
5837
5838
LLVM::ModuleTranslation &moduleTranslation) {
5838
5839
// Amend omp.declare_target by deleting the IR of the outlined functions
5839
5840
// created for target regions. They cannot be filtered out from MLIR earlier
@@ -5856,6 +5857,11 @@ convertDeclareTargetAttr(Operation *op, mlir::omp::DeclareTargetAttr attribute,
5856
5857
moduleTranslation.lookupFunction (funcOp.getName ());
5857
5858
llvmFunc->dropAllReferences ();
5858
5859
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 ());
5859
5865
}
5860
5866
}
5861
5867
return success ();
@@ -6300,9 +6306,12 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::amendOperation(
6300
6306
.Case (" omp.declare_target" ,
6301
6307
[&](Attribute attr) {
6302
6308
if (auto declareTargetAttr =
6303
- dyn_cast<omp::DeclareTargetAttr>(attr))
6309
+ dyn_cast<omp::DeclareTargetAttr>(attr)) {
6310
+ llvm::OpenMPIRBuilder *ompBuilder =
6311
+ moduleTranslation.getOpenMPBuilder ();
6304
6312
return convertDeclareTargetAttr (op, declareTargetAttr,
6305
- moduleTranslation);
6313
+ ompBuilder, moduleTranslation);
6314
+ }
6306
6315
return failure ();
6307
6316
})
6308
6317
.Case (" omp.requires" ,
0 commit comments