This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Add hlfir.copy_in and hlfir.copy_out codegen to FIR.
ClosedPublic

Authored by jeanPerier on Jan 24 2023, 7:38 AM.

Details

Summary

Use runtime Assign to deal with the copy (and the temporary creation, so
that this code can deal with polymorphic temps without any change).

Using Assign for the copy is desired here since the copy happens when
the data is not contiguous, and it happens inside an if/then which
makes it hard to optimize.
See https://github.com/llvm/llvm-project/commit/2b60ed405b8110b20ab2e383839759ea34003127
for more details (note that, contrary to this last commit, the code at
hand is only dealing with copy-in/copy-out, it is not intended to deal
with preparing VALUE arguments).

Depends on D142342

Diff Detail

Event Timeline

jeanPerier created this revision.Jan 24 2023, 7:38 AM
jeanPerier requested review of this revision.Jan 24 2023, 7:38 AM
PeteSteinfeld accepted this revision.Jan 24 2023, 12:49 PM

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Jan 24 2023, 12:49 PM
vzakhari accepted this revision.Jan 24 2023, 1:11 PM
vzakhari added inline comments.
flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp
159

nit: maybe rename genHeapTempFromSourceBox to genAllocatableTempFromSourceBox so that it is clear that it returns a box with the allocatable flag set (and we need to reset it afterwards). I think Allocatable always implies Heap, so such naming should be more telling.

jeanPerier added inline comments.Jan 25 2023, 1:08 AM
flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp
159

Thanks, that is clearer.