[flang-commits] [flang] a88ea8f - [flang][cuda] Update memory effect on fir.cuda_allocate op (#88930)

via flang-commits flang-commits at lists.llvm.org
Wed Apr 17 08:43:14 PDT 2024


Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-04-17T08:43:11-07:00
New Revision: a88ea8fbb3953c2fe2887438baf342e381a79d8b

URL: https://github.com/llvm/llvm-project/commit/a88ea8fbb3953c2fe2887438baf342e381a79d8b
DIFF: https://github.com/llvm/llvm-project/commit/a88ea8fbb3953c2fe2887438baf342e381a79d8b.diff

LOG: [flang][cuda] Update memory effect on fir.cuda_allocate op (#88930)

Add MemRead effect on the box operand as the descriptor might be read
when performing the allocation of the data.

Also update the expected type of the box operand to be a reference.
Check in the verifier that this is a reference to a box or class type.

This addresses the comment made post commit on #88586

Added: 
    

Modified: 
    flang/include/flang/Optimizer/Dialect/FIROps.td
    flang/lib/Optimizer/Dialect/FIROps.cpp
    flang/test/Fir/cuf-invalid.fir

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 580e840587abb2..92790a691e4731 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -3200,7 +3200,7 @@ def fir_CUDAAllocateOp : fir_Op<"cuda_allocate", [AttrSizedOperandSegments,
     is initialized before with the standard flang runtime calls.
   }];
 
-  let arguments = (ins Arg<AnyRefOrBoxType, "", [MemWrite]>:$box,
+  let arguments = (ins Arg<fir_ReferenceType, "", [MemRead, MemWrite]>:$box,
                        Arg<Optional<AnyRefOrBoxType>, "", [MemWrite]>:$errmsg,
                        Optional<AnyIntegerType>:$stream,
                        Arg<Optional<AnyRefOrBoxType>, "", [MemWrite]>:$pinned,

diff  --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index be27256d911b31..5c24c95db427aa 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -3998,7 +3998,7 @@ mlir::LogicalResult fir::CUDAAllocateOp::verify() {
     return emitOpError("pinned and stream cannot appears at the same time");
   if (!fir::unwrapRefType(getBox().getType()).isa<fir::BaseBoxType>())
     return emitOpError(
-        "expect box to be a reference to/or a class or box type value");
+        "expect box to be a reference to a class or box type value");
   if (getSource() &&
       !fir::unwrapRefType(getSource().getType()).isa<fir::BaseBoxType>())
     return emitOpError(

diff  --git a/flang/test/Fir/cuf-invalid.fir b/flang/test/Fir/cuf-invalid.fir
index 5d3aa55cf346a4..6c533a32ccf9ba 100644
--- a/flang/test/Fir/cuf-invalid.fir
+++ b/flang/test/Fir/cuf-invalid.fir
@@ -16,7 +16,7 @@ func.func @_QPsub1() {
 
 func.func @_QPsub1() {
   %1 = fir.alloca i32
-  // expected-error at +1{{'fir.cuda_allocate' op expect box to be a reference to/or a class or box type value}}
+  // expected-error at +1{{'fir.cuda_allocate' op expect box to be a reference to a class or box type value}}
   %2 = fir.cuda_allocate %1 : !fir.ref<i32> {cuda_attr = #fir.cuda<device>} -> i32
   return
 }


        


More information about the flang-commits mailing list