[flang-commits] [flang] [flang] Lower Cray pointee references without a runtime call. (PR #230699)
via flang-commits
flang-commits at lists.llvm.org
Fri Oct 9 16:03:42 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-codegen
@llvm/pr-subscribers-flang-fir-hlfir
Author: Greg Williamson (fundies)
<details>
<summary>Changes</summary>
Each Cray pointee reference called a runtime function to update the pointee's descriptor, which blocked LLVM optimizations and slowed down loops that use pointees. This replaces the call with a new `fir.box_set_addr` op that lowers to a single store, so LLVM can optimize it.
Assisted-by: Claude Code
---
Patch is 52.31 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/230699.diff
11 Files Affected:
- (modified) flang/include/flang/Optimizer/Dialect/FIROps.td (+30)
- (modified) flang/lib/Lower/ConvertExprToHLFIR.cpp (+4-8)
- (modified) flang/lib/Optimizer/CodeGen/CodeGen.cpp (+25-1)
- (modified) flang/lib/Optimizer/Dialect/FIROps.cpp (+10)
- (added) flang/test/Fir/box-set-addr.fir (+41)
- (modified) flang/test/Fir/invalid.fir (+8)
- (added) flang/test/Integration/cray-pointee-loop.f90 (+37)
- (modified) flang/test/Lower/HLFIR/cray-pointers.f90 (+14-42)
- (modified) flang/test/Lower/OpenMP/cray-pointers01.f90 (+4-6)
- (modified) flang/test/Lower/OpenMP/cray-pointers02.f90 (+21-21)
- (modified) flang/test/Lower/cray-pointer.f90 (+16-48)
``````````diff
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 7fc12430d0663f..cde6f03e251297 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -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);
+
+ let assemblyFormat = [{
+ $addr `to` $box_ref attr-dict `:` type($addr) `,` type($box_ref)
+ }];
+
+ let hasVerifier = 1;
+}
+
def fir_BoxCharLenOp : fir_SimpleOp<"boxchar_len", [NoMemoryEffect]> {
let summary = "return the LEN type parameter from a boxchar value";
diff --git a/flang/lib/Lower/ConvertExprToHLFIR.cpp b/flang/lib/Lower/ConvertExprToHLFIR.cpp
index 24c990141be552..fd88d04e1def87 100644
--- a/flang/lib/Lower/ConvertExprToHLFIR.cpp
+++ b/flang/lib/Lower/ConvertExprToHLFIR.cpp
@@ -28,7 +28,6 @@
#include "flang/Optimizer/Builder/IntrinsicCall.h"
#include "flang/Optimizer/Builder/MutableBox.h"
#include "flang/Optimizer/Builder/Runtime/Derived.h"
-#include "flang/Optimizer/Builder/Runtime/Pointer.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/Dialect/FIRAttr.h"
#include "flang/Optimizer/HLFIR/HLFIROps.h"
@@ -362,13 +361,10 @@ class HlfirDesignatorBuilder {
mlir::Value ptrVal = fir::LoadOp::create(builder, loc, cast);
// Update the base_addr to the value of the Cray pointer.
- // This is a hacky way to do the update, and it may harm
- // performance around Cray pointer references.
- // TODO: we should introduce an operation that updates
- // just the base_addr of the given box. The CodeGen
- // will just convert it into a single store.
- fir::runtime::genPointerAssociateScalar(builder, loc, varDef->getBase(),
- ptrVal);
+ // fir.box_set_addr is lowered to a single store into the
+ // descriptor, which LLVM can see through (and hoist out of loops
+ // when the Cray pointer does not change), unlike a runtime call.
+ fir::BoxSetAddrOp::create(builder, loc, ptrVal, varDef->getBase());
}
return *varDef;
}
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 4923cfe2e18787..fc9bf75033ac0d 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -512,6 +512,30 @@ struct BoxAddrOpConversion : public fir::FIROpConversion<fir::BoxAddrOp> {
}
};
+/// Lower `fir.box_set_addr` to a single store of the new base address into the
+/// base_addr field of the descriptor in memory.
+struct BoxSetAddrOpConversion : public fir::FIROpConversion<fir::BoxSetAddrOp> {
+ using FIROpConversion::FIROpConversion;
+
+ llvm::LogicalResult
+ matchAndRewrite(fir::BoxSetAddrOp op, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const override {
+ auto boxTy = mlir::cast<fir::BaseBoxType>(
+ fir::unwrapRefType(op.getBoxRef().getType()));
+ TypePair boxTyPair = getBoxTypePair(boxTy);
+ mlir::Location loc = op.getLoc();
+ auto addrField = mlir::LLVM::GEPOp::create(
+ rewriter, loc, ::getLlvmPtrType(op.getContext()), boxTyPair.llvm,
+ adaptor.getBoxRef(),
+ llvm::ArrayRef<mlir::LLVM::GEPArg>{0, kAddrPosInBox});
+ auto store = mlir::LLVM::StoreOp::create(rewriter, loc, adaptor.getAddr(),
+ addrField);
+ attachTBAATag(store, boxTyPair.fir, nullptr, addrField);
+ rewriter.eraseOp(op);
+ return mlir::success();
+ }
+};
+
/// Convert `!fir.boxchar_len` to `!llvm.extractvalue` for the 2nd part of the
/// boxchar.
struct BoxCharLenOpConversion : public fir::FIROpConversion<fir::BoxCharLenOp> {
@@ -5118,7 +5142,7 @@ void fir::populateFIRToLLVMConversionPatterns(
BoxTypeDescOpConversion, CallOpConversion, CmpcOpConversion,
VolatileCastOpConversion, ConvertOpConversion, CoordinateOpConversion,
CopyOpConversion, DTEntryOpConversion, DeclareOpConversion,
- DeclareValueOpConversion,
+ DeclareValueOpConversion, BoxSetAddrOpConversion,
DoConcurrentSpecifierOpConversion<fir::LocalitySpecifierOp>,
DoConcurrentSpecifierOpConversion<fir::DeclareReductionOp>,
CreateBoxOpConversion, DivcOpConversion, EmboxOpConversion,
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 606d47631488bb..dda932b1f38238 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -1375,6 +1375,16 @@ mlir::Speculation::Speculatability fir::BoxAddrOp::getSpeculatability() {
: mlir::Speculation::Speculatable;
}
+//===----------------------------------------------------------------------===//
+// BoxSetAddrOp
+//===----------------------------------------------------------------------===//
+
+llvm::LogicalResult fir::BoxSetAddrOp::verify() {
+ if (!mlir::isa<fir::BaseBoxType>(fir::unwrapRefType(getBoxRef().getType())))
+ return emitOpError("box_ref must be a reference to a fir.box or fir.class");
+ return mlir::success();
+}
+
//===----------------------------------------------------------------------===//
// BoxCharLenOp
//===----------------------------------------------------------------------===//
diff --git a/flang/test/Fir/box-set-addr.fir b/flang/test/Fir/box-set-addr.fir
new file mode 100644
index 00000000000000..9142108bd4e751
--- /dev/null
+++ b/flang/test/Fir/box-set-addr.fir
@@ -0,0 +1,41 @@
+// Test fir.box_set_addr parsing/printing and conversion to LLVM.
+// RUN: fir-opt %s | fir-opt | FileCheck %s --check-prefix=FIR
+// RUN: fir-opt --fir-to-llvm-ir="target=aarch64-unknown-linux-gnu" %s | FileCheck %s --check-prefix=LLVM
+
+func.func @set_addr_array(%p : !fir.ptr<i64>, %desc : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>) {
+ fir.box_set_addr %p to %desc : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
+ return
+}
+// FIR-LABEL: func.func @set_addr_array(
+// FIR-SAME: %[[P:.*]]: !fir.ptr<i64>, %[[D:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>)
+// FIR: fir.box_set_addr %[[P]] to %[[D]] : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
+
+// LLVM-LABEL: llvm.func @set_addr_array(
+// LLVM-SAME: %[[P:.*]]: !llvm.ptr, %[[D:.*]]: !llvm.ptr)
+// LLVM: %[[F:.*]] = llvm.getelementptr %[[D]][0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)>
+// LLVM-NEXT: llvm.store %[[P]], %[[F]] : !llvm.ptr, !llvm.ptr
+// LLVM-NEXT: llvm.return
+
+func.func @set_addr_char(%p : !fir.ptr<i64>, %desc : !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>) {
+ fir.box_set_addr %p to %desc : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>
+ return
+}
+// FIR-LABEL: func.func @set_addr_char(
+// FIR: fir.box_set_addr %{{.*}} to %{{.*}} : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>
+
+// LLVM-LABEL: llvm.func @set_addr_char(
+// LLVM-SAME: %[[P:.*]]: !llvm.ptr, %[[D:.*]]: !llvm.ptr)
+// LLVM: %[[F:.*]] = llvm.getelementptr %[[D]][0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>
+// LLVM-NEXT: llvm.store %[[P]], %[[F]] : !llvm.ptr, !llvm.ptr
+
+func.func @set_addr_derived(%p : !fir.ptr<i64>, %desc : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.type<t{r:f32,i:i32}>>>>>) {
+ fir.box_set_addr %p to %desc : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.type<t{r:f32,i:i32}>>>>>
+ return
+}
+// FIR-LABEL: func.func @set_addr_derived(
+// FIR: fir.box_set_addr %{{.*}} to %{{.*}} : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.type<t{r:f32,i:i32}>>>>>
+
+// LLVM-LABEL: llvm.func @set_addr_derived(
+// LLVM-SAME: %[[P:.*]]: !llvm.ptr, %[[D:.*]]: !llvm.ptr)
+// LLVM: %[[F:.*]] = llvm.getelementptr %[[D]][0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr, array<1 x i64>)>
+// LLVM-NEXT: llvm.store %[[P]], %[[F]] : !llvm.ptr, !llvm.ptr
diff --git a/flang/test/Fir/invalid.fir b/flang/test/Fir/invalid.fir
index 8964df1d2e93e6..5ca0ae154bd1bb 100644
--- a/flang/test/Fir/invalid.fir
+++ b/flang/test/Fir/invalid.fir
@@ -1400,3 +1400,11 @@ func.func @allocmem_bad_alignment() -> !fir.heap<!fir.array<10xf32>> {
%0 = fir.allocmem !fir.array<10xf32> {alignment = 3 : i64}
return %0 : !fir.heap<!fir.array<10xf32>>
}
+
+// -----
+
+func.func @box_set_addr_not_a_box(%p : !fir.ptr<i64>, %r : !fir.ref<i64>) {
+ // expected-error at +1 {{'fir.box_set_addr' op box_ref must be a reference to a fir.box or fir.class}}
+ fir.box_set_addr %p to %r : !fir.ptr<i64>, !fir.ref<i64>
+ return
+}
diff --git a/flang/test/Integration/cray-pointee-loop.f90 b/flang/test/Integration/cray-pointee-loop.f90
new file mode 100644
index 00000000000000..f9ef63b954a1d0
--- /dev/null
+++ b/flang/test/Integration/cray-pointee-loop.f90
@@ -0,0 +1,37 @@
+! Check that re-associating a Cray pointee with its Cray pointer before each
+! reference does not leave a runtime call (or descriptor reloads) in the loop.
+! RUN: %flang_fc1 -emit-llvm -O2 -o - %s | FileCheck %s
+
+integer function find(p, n, cur)
+ integer(8) :: p
+ integer :: n, cur, i
+ integer :: pg(*)
+ pointer (pp, pg)
+ pp = p
+ find = 0
+ do i = 1, n
+ if (pg(i) == cur) then
+ find = i
+ return
+ end if
+ end do
+end function
+! CHECK-LABEL: define {{.*}}i32 @find_(
+! CHECK-NOT: call
+! CHECK-NOT: alloca
+! CHECK: ret i32
+
+subroutine copy_out(p, n, v)
+ integer(8) :: p, n, i
+ integer(4) :: v(*)
+ integer(4) :: buf(*)
+ pointer (pb, buf)
+ pb = p
+ do i = 1, n
+ v(i) = buf(i)
+ end do
+end subroutine
+! CHECK-LABEL: define void @copy_out_(
+! CHECK-NOT: PointerAssociateScalar
+! CHECK-NOT: alloca
+! CHECK: ret void
diff --git a/flang/test/Lower/HLFIR/cray-pointers.f90 b/flang/test/Lower/HLFIR/cray-pointers.f90
index 818ad8098a7e1a..30951996f67087 100644
--- a/flang/test/Lower/HLFIR/cray-pointers.f90
+++ b/flang/test/Lower/HLFIR/cray-pointers.f90
@@ -19,9 +19,7 @@ end subroutine test1
! CHECK: fir.store %[[VAL_14]] to %[[VAL_12]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<i64>) -> !fir.ref<!fir.ptr<i64>>
! CHECK: %[[VAL_16:.*]] = fir.load %[[VAL_15]] : !fir.ref<!fir.ptr<i64>>
-! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_12]]#0 : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>) -> !fir.ref<!fir.box<none>>
-! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_16]] : (!fir.ptr<i64>) -> !fir.llvm_ptr<i8>
-! CHECK: fir.call @_FortranAPointerAssociateScalar(%[[VAL_17]], %[[VAL_18]]) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> ()
+! CHECK: fir.box_set_addr %[[VAL_16]] to %[[VAL_12]]#0 : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_12]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
! CHECK: %[[VAL_21:.*]] = arith.constant 7 : index
! CHECK: %[[VAL_22:.*]] = hlfir.designate %[[VAL_20]] (%[[VAL_21]]) : (!fir.box<!fir.ptr<!fir.array<?xf32>>>, index) -> !fir.ref<f32>
@@ -45,9 +43,7 @@ end subroutine test2
! CHECK: fir.store %[[VAL_26]] to %[[VAL_24]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<i64>) -> !fir.ref<!fir.ptr<i64>>
! CHECK: %[[VAL_28:.*]] = fir.load %[[VAL_27]] : !fir.ref<!fir.ptr<i64>>
-! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_24]]#0 : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>) -> !fir.ref<!fir.box<none>>
-! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_28]] : (!fir.ptr<i64>) -> !fir.llvm_ptr<i8>
-! CHECK: fir.call @_FortranAPointerAssociateScalar(%[[VAL_29]], %[[VAL_30]]) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> ()
+! CHECK: fir.box_set_addr %[[VAL_28]] to %[[VAL_24]]#0 : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
! CHECK: %[[VAL_32:.*]] = fir.load %[[VAL_24]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
! CHECK: %[[VAL_33:.*]] = arith.constant 7 : index
! CHECK: %[[VAL_34:.*]] = hlfir.designate %[[VAL_32]] (%[[VAL_33]]) : (!fir.box<!fir.ptr<!fir.array<?xf32>>>, index) -> !fir.ref<f32>
@@ -73,9 +69,7 @@ end subroutine test3
! CHECK: fir.store %[[VAL_31]] to %[[VAL_29]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,11>>>>>
! CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<i64>) -> !fir.ref<!fir.ptr<i64>>
! CHECK: %[[VAL_33:.*]] = fir.load %[[VAL_32]] : !fir.ref<!fir.ptr<i64>>
-! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_29]]#0 : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,11>>>>>) -> !fir.ref<!fir.box<none>>
-! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_33]] : (!fir.ptr<i64>) -> !fir.llvm_ptr<i8>
-! CHECK: fir.call @_FortranAPointerAssociateScalar(%[[VAL_34]], %[[VAL_35]]) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> ()
+! CHECK: fir.box_set_addr %[[VAL_33]] to %[[VAL_29]]#0 : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,11>>>>>
! CHECK: %[[VAL_37:.*]] = fir.load %[[VAL_29]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,11>>>>>
! CHECK: %[[VAL_38:.*]] = arith.constant 7 : index
! CHECK: %[[VAL_39:.*]] = hlfir.designate %[[VAL_37]] (%[[VAL_38]]) typeparams %[[VAL_8]] : (!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,11>>>>, index, index) -> !fir.ref<!fir.char<1,11>>
@@ -101,9 +95,7 @@ end subroutine test4
! CHECK: fir.store %[[VAL_15]] to %[[VAL_13]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>
! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<i64>) -> !fir.ref<!fir.ptr<i64>>
! CHECK: %[[VAL_23:.*]] = fir.load %[[VAL_22]] : !fir.ref<!fir.ptr<i64>>
-! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_13]]#0 : (!fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>) -> !fir.ref<!fir.box<none>>
-! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_23]] : (!fir.ptr<i64>) -> !fir.llvm_ptr<i8>
-! CHECK: fir.call @_FortranAPointerAssociateScalar(%[[VAL_24]], %[[VAL_25]]) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> ()
+! CHECK: fir.box_set_addr %[[VAL_23]] to %[[VAL_13]]#0 : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>
! CHECK: %[[VAL_27:.*]] = fir.load %[[VAL_13]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>
! CHECK: %[[VAL_28:.*]] = fir.box_addr %[[VAL_27]] : (!fir.box<!fir.ptr<!fir.char<1,?>>>) -> !fir.ptr<!fir.char<1,?>>
! CHECK: %[[VAL_29:.*]] = fir.emboxchar %[[VAL_28]], %[[VAL_8]] : (!fir.ptr<!fir.char<1,?>>, i32) -> !fir.boxchar<1>
@@ -132,9 +124,7 @@ end subroutine test5
! CHECK: fir.store %[[VAL_15]] to %[[VAL_13]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.type<_QFtest5Tt{{(,sequence)?}}{r:f32,i:i32}>>>>>
! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<i64>) -> !fir.ref<!fir.ptr<i64>>
! CHECK: %[[VAL_17:.*]] = fir.load %[[VAL_16]] : !fir.ref<!fir.ptr<i64>>
-! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_13]]#0 : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.type<_QFtest5Tt{{(,sequence)?}}{r:f32,i:i32}>>>>>) -> !fir.ref<!fir.box<none>>
-! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]] : (!fir.ptr<i64>) -> !fir.llvm_ptr<i8>
-! CHECK: fir.call @_FortranAPointerAssociateScalar(%[[VAL_18]], %[[VAL_19]]) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> ()
+! CHECK: fir.box_set_addr %[[VAL_17]] to %[[VAL_13]]#0 : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.type<_QFtest5Tt{{(,sequence)?}}{r:f32,i:i32}>>>>>
! CHECK: %[[VAL_21:.*]] = fir.load %[[VAL_13]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.type<_QFtest5Tt{{(,sequence)?}}{r:f32,i:i32}>>>>>
! CHECK: %[[VAL_22:.*]] = arith.constant 7 : index
! CHECK: %[[VAL_23:.*]] = hlfir.designate %[[VAL_21]] (%[[VAL_22]]) : (!fir.box<!fir.ptr<!fir.array<?x!fir.type<_QFtest5Tt{{(,sequence)?}}{r:f32,i:i32}>>>>, index) -> !fir.ref<!fir.type<_QFtest5Tt{{(,sequence)?}}{r:f32,i:i32}>>
@@ -176,18 +166,14 @@ end subroutine test6
! CHECK: %[[VAL_49:.*]] = fir.convert %[[VAL_5]]#0 : (!fir.ref<i64>) -> !fir.ref<!fir.ptr<i64>>
! CHECK: %[[VAL_50:.*]] = fir.load %[[VAL_49]] : !fir.ref<!fir.ptr<i64>>
-! CHECK: %[[VAL_51:.*]] = fir.convert %[[VAL_20]]#0 : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>) -> !fir.ref<!fir.box<none>>
-! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_50]] : (!fir.ptr<i64>) -> !fir.llvm_ptr<i8>
-! CHECK: fir.call @_FortranAPointerAssociateScalar(%[[VAL_51]], %[[VAL_52]]) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> ()
+! CHECK: fir.box_set_addr %[[VAL_50]] to %[[VAL_20]]#0 : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>
! CHECK: %[[VAL_54:.*]] = fir.load %[[VAL_20]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>
! CHECK: %[[VAL_55:.*]] = arith.constant 9 : index
! CHECK: %[[VAL_56:.*]] = hlfir.designate %[[VAL_54]] (%[[VAL_55]]) typeparams %[[VAL_11]] : (!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>, index, i32) -> !fir.boxchar<1>
! CHECK: %[[VAL_57:.*]] = fir.convert %[[VAL_5]]#0 : (!fir.ref<i64>) -> !fir.ref<!fir.ptr<i64>>
! CHECK: %[[VAL_58:.*]] = fir.load %[[VAL_57]] : !fir.ref<!fir.ptr<i64>>
-! CHECK: %[[VAL_59:.*]] = fir.convert %[[VAL_46]]#0 : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>) -> !fir.ref<!fir.box<none>>
-! CHECK: %[[VAL_60:.*]] = fir.convert %[[VAL_58]] : (!fir.ptr<i64>) -> !fir.llvm_ptr<i8>
-! CHECK: fir.call @_FortranAPointerAssociateScalar(%[[VAL_59]], %[[VAL_60]]) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> ()
+! CHECK: fir.box_set_addr %[[VAL_58]] to %[[VAL_46]]#0 : !fir.ptr<i64>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
! CHECK: %[[VAL_62:.*]] = fir.load %[[VAL_46]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
! CHECK: %[[VAL_63:.*]] = arith.constant 5 : index
! CHECK: %[[VAL_64:.*]] = hlfir.designate %[[VAL_62]] (%[[VAL_63]]) : (!fir.box<!fir.ptr<!fir.array<?xf32>>>, index) -> !fir.ref<f32>
@@ -214,9 +200,7 @@ end subroutine test7
! CHECK: fir.store %[[VAL_11]] to %[[VAL_9]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]]#0 : (!fir.ref<i64>) -> !fir.ref<!fir.ptr<i64>>
! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_14]] : !fir.ref<!fir.ptr<i64>>
-! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_9]]#0 : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
-! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_15]] : (!fir.ptr<i64>) -> !fir.llvm_ptr<i8>
-! CHECK: fir.call @_FortranAPointerAssociateScalar(%[[VAL_16]], %[[VAL_17]]) fastmath<contract> : ...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/230699
More information about the flang-commits
mailing list