[flang-commits] [flang] [flang][cuda] Create descriptor in managed memory when emboxing fir.box_addr value (PR #120980)

via flang-commits flang-commits at lists.llvm.org
Mon Dec 23 09:09:54 PST 2024


https://github.com/khaki3 approved this pull request.

It looks good to me. The new test checks if we allocate an extra descriptor with `_FortranACUFAllocDescriptor`.

```mlir
    %3 = fir.call @_FortranACUFAllocDescriptor(%1, %2, %c11_i32) : (i64, !fir.ref<i8>, i32) -> !fir.ref<!fir.box<none>>
    %4 = fir.convert %3 : (!fir.ref<!fir.box<none>>) -> !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>
    ...
    %7 = fir.load %4 : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>
    %8 = fir.box_addr %7 : (!fir.box<!fir.heap<!fir.array<?x?xi32>>>) -> !fir.heap<!fir.array<?x?xi32>>
    ...
    %11 = fircg.ext_embox %8(%9#1, %10#1) origin %9#0, %10#0[%c1, %c10, %c1, %c1, %c2, %c1] : (!fir.heap<!fir.array<?x?xi32>>, index, index, index, index, index, index, index, index, index, index) -> !fir.box<!fir.array<10x2xi32>>
  ...
  func.func private @_FortranACUFFreeDescriptor(!fir.ref<!fir.box<none>>, !fir.ref<i8>, i32) -> none attributes {fir.runtime}
...
// CHECK-COUNT-3: llvm.call @_FortranACUFAllocDescriptor
```


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


More information about the flang-commits mailing list