[flang-commits] [flang] [flang][cuda] Add fir.deallocate operation (PR #88839)

via flang-commits flang-commits at lists.llvm.org
Tue Apr 16 02:50:43 PDT 2024


================
@@ -3222,4 +3222,29 @@ def fir_CUDAAllocateOp : fir_Op<"cuda_allocate", [AttrSizedOperandSegments,
   let hasVerifier = 1;
 }
 
+def fir_CUDADeallocateOp : fir_Op<"cuda_deallocate",
+    [MemoryEffects<[MemFree<DefaultResource>]>]> {
+  let summary = "Perform the device deallocation of data of an allocatable";
+
+  let description = [{
+    The fir.cuda_deallocate operation performs the deallocation on the device
+    of the data of an allocatable.
+  }];
+
+  let arguments = (ins Arg<AnyRefOrBoxType, "", [MemWrite]>:$box,
----------------
jeanPerier wrote:

Technically it will have both a read and write effect (same for allocate actually): the runtime will/may read info from the incoming descriptor in both cases. I guess the memory effect would anyway prevent optimizers to think they can skip previous writes if this is the only user of box left, but probably better to add it.

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


More information about the flang-commits mailing list