This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Implemented addressing an element of a polymorphic array.
ClosedPublic

Authored by vzakhari on Jun 5 2023, 2:50 PM.

Details

Summary

The changes convert hlfir.designate to fir.array_coor/fir.embox
to represent a subscripted element of a polymorphic array.
The type information is conveyed via the fir.embox's source_box.

Diff Detail

Event Timeline

vzakhari created this revision.Jun 5 2023, 2:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 2:50 PM
vzakhari requested review of this revision.Jun 5 2023, 2:50 PM
tblah added inline comments.Jun 6 2023, 2:23 AM
flang/test/HLFIR/designate-codegen.fir
204

This value is unused. Are there cases when it is used?

vzakhari added inline comments.Jun 6 2023, 8:24 AM
flang/test/HLFIR/designate-codegen.fir
204

This rebox is part of hlfir.declare HLFIR-to-FIR conversion pattern. The local box is used, for example, here:

subroutine test(x)
  real x(:)
  call callee(x)
end subroutine test
%2 = fir.declare %arg0 {uniq_name = "_QFtestEx"} : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>
%3 = fir.rebox %2 : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>
%4 = fir.convert %3 : (!fir.box<!fir.array<?xf32>>) -> !fir.box<none>
%5 = fir.call @_FortranAIsContiguous(%4) : (!fir.box<none>) -> i1
%6 = fir.if %5 -> (!fir.box<!fir.array<?xf32>>) {
tblah accepted this revision.Jun 6 2023, 9:37 AM

Thanks for explaining. This looks good to me.

This revision is now accepted and ready to land.Jun 6 2023, 9:37 AM