@@ -5872,6 +5872,7 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
5872
5872
5873
5873
static LogicalResult
5874
5874
convertDeclareTargetAttr (Operation *op, mlir::omp::DeclareTargetAttr attribute,
5875
+ llvm::OpenMPIRBuilder *ompBuilder,
5875
5876
LLVM::ModuleTranslation &moduleTranslation) {
5876
5877
// Amend omp.declare_target by deleting the IR of the outlined functions
5877
5878
// created for target regions. They cannot be filtered out from MLIR earlier
@@ -5894,6 +5895,11 @@ convertDeclareTargetAttr(Operation *op, mlir::omp::DeclareTargetAttr attribute,
5894
5895
moduleTranslation.lookupFunction (funcOp.getName ());
5895
5896
llvmFunc->dropAllReferences ();
5896
5897
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 ());
5897
5903
}
5898
5904
}
5899
5905
return success ();
@@ -6338,9 +6344,12 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::amendOperation(
6338
6344
.Case (" omp.declare_target" ,
6339
6345
[&](Attribute attr) {
6340
6346
if (auto declareTargetAttr =
6341
- dyn_cast<omp::DeclareTargetAttr>(attr))
6347
+ dyn_cast<omp::DeclareTargetAttr>(attr)) {
6348
+ llvm::OpenMPIRBuilder *ompBuilder =
6349
+ moduleTranslation.getOpenMPBuilder ();
6342
6350
return convertDeclareTargetAttr (op, declareTargetAttr,
6343
- moduleTranslation);
6351
+ ompBuilder, moduleTranslation);
6352
+ }
6344
6353
return failure ();
6345
6354
})
6346
6355
.Case (" omp.requires" ,
0 commit comments