[flang-commits] [flang] [flang] Lower Cray pointee references without a runtime call. (PR #230699)

via flang-commits flang-commits at lists.llvm.org
Mon Oct 12 06:55:51 PDT 2026


================
@@ -1275,6 +1275,36 @@ def fir_BoxAddrOp
   }];
 }
 
+def fir_BoxSetAddrOp : fir_Op<"box_set_addr", []> {
+  let summary = "update the base address of a descriptor in memory";
+
+  let description = [{
+    Store the address `addr` into the base address field of the descriptor
+    held in memory at `box_ref`.  All other fields of the descriptor (type,
+    rank, attributes, bounds, strides, element size) are left unchanged.
+
+    It is used to re-associate the descriptor of a Cray pointee with the
+    current value of its Cray pointer before each reference of the pointee.
+    Code generation lowers it to a single store into the descriptor, so the
+    update is visible to (and can be optimized by) LLVM, unlike a call to the
+    PointerAssociateScalar runtime function.
+
+    ```
+      fir.box_set_addr %p to %desc : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
+    ```
+  }];
+
+  let arguments = (ins AnyReferenceLike:$addr,
+                       Arg<AnyReferenceLike, "descriptor in memory",
+                           [MemRead, MemWrite]>:$box_ref);
----------------
jeanPerier wrote:

What is the rational for the `MemRead` effect here?

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


More information about the flang-commits mailing list