This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fixed managing copy-in/copy-out temps.
ClosedPublic

Authored by vzakhari on May 22 2023, 12:08 PM.

Details

Summary

There are several observations regarding the copy-in/copy-out:

  • Actual argument associated with INTENT(OUT) dummy argument that requires finalization (7.5.6.3 p. 7) may be read by the finalization function, so a copy-in is required.
  • A temporary created for the copy-in/copy-out must be destroyed without finalization after the call (or after the corresponding copy-out), otherwise, memory leaks may occur.
  • The copy-out assignment must not perform finalization for the LHS.
  • The copy-out assignment from the temporary to the actual argument may or may not need to initialize the LHS.

This change-set introduces new runtime methods: CopyOutAssign and
DestroyWithoutFinalization. They are called by the compiler generated
code to match the behavior described above.

Diff Detail

Event Timeline

vzakhari created this revision.May 22 2023, 12:08 PM
vzakhari requested review of this revision.May 22 2023, 12:08 PM
jeanPerier accepted this revision.May 22 2023, 11:39 PM

Looks great, thank you Slava

This revision is now accepted and ready to land.May 22 2023, 11:39 PM
This revision was automatically updated to reflect the committed changes.