[flang-commits] [flang] [flang][cuda] Use fir.cuda_deallocate for automatic deallocation (PR #89662)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Mon Apr 22 13:55:48 PDT 2024


================
@@ -4187,21 +4187,24 @@ void Fortran::lower::attachDeclarePostDeallocAction(
 
   std::stringstream fctName;
   fctName << converter.mangleName(sym) << declarePostDeallocSuffix.str();
-  mlir::Operation &op = builder.getInsertionBlock()->back();
-  if (op.hasAttr(mlir::acc::getDeclareActionAttrName())) {
-    auto attr = op.getAttrOfType<mlir::acc::DeclareActionAttr>(
+  mlir::Operation *op = &builder.getInsertionBlock()->back();
+  if (mlir::isa<fir::ResultOp>(*op))
----------------
vzakhari wrote:

nit: maybe it is worth adding an assertion here that `ResultOp` does not have operands - in this case, it may happen that the operand definition operation precedes `ResultOp`.  It seems it may go wrong other different ways, but asserting the suspicious case with operands in `ResultOp` looks reasonable to me.

https://github.com/llvm/llvm-project/pull/89662


More information about the flang-commits mailing list